Show an error dialog if location permission is denied (#7531)
This commit is contained in:
parent
25cd1a8a43
commit
22c2aa37d7
2 changed files with 39 additions and 0 deletions
|
@ -25,6 +25,8 @@ import { _t } from '../../../languageHandler';
|
|||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||
import MemberAvatar from '../avatars/MemberAvatar';
|
||||
import MatrixClientContext from '../../../contexts/MatrixClientContext';
|
||||
import Modal from '../../../Modal';
|
||||
import ErrorDialog from '../dialogs/ErrorDialog';
|
||||
|
||||
interface IProps {
|
||||
sender: RoomMember;
|
||||
|
@ -106,6 +108,20 @@ class LocationPicker extends React.Component<IProps, IState> {
|
|||
this.geolocate.trigger();
|
||||
});
|
||||
|
||||
this.geolocate.on('error', (e: GeolocationPositionError) => {
|
||||
this.props.onFinished();
|
||||
logger.error("Could not fetch location", e);
|
||||
Modal.createTrackedDialog(
|
||||
'Could not fetch location',
|
||||
'',
|
||||
ErrorDialog,
|
||||
{
|
||||
title: _t("Could not fetch location"),
|
||||
description: positionFailureMessage(e.code),
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
this.geolocate.on('geolocate', this.onGeolocate);
|
||||
} catch (e) {
|
||||
logger.error("Failed to render map", e.error);
|
||||
|
@ -197,3 +213,21 @@ export function getGeoUri(position: GeolocationPosition): string {
|
|||
}
|
||||
|
||||
export default LocationPicker;
|
||||
|
||||
function positionFailureMessage(code: number): string {
|
||||
switch (code) {
|
||||
case 1: return _t(
|
||||
"Element was denied permission to fetch your location. " +
|
||||
"Please allow location access in your browser settings.",
|
||||
);
|
||||
case 2: return _t(
|
||||
"Failed to fetch your location. Please try again later.",
|
||||
);
|
||||
case 3: return _t(
|
||||
"Timed out trying to fetch your location. Please try again later.",
|
||||
);
|
||||
case 4: return _t(
|
||||
"Unknown error fetching location. Please try again later.",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2137,6 +2137,11 @@
|
|||
"Share location": "Share location",
|
||||
"We couldn’t send your location": "We couldn’t send your location",
|
||||
"Element could not send your location. Please try again later.": "Element could not send your location. Please try again later.",
|
||||
"Could not fetch location": "Could not fetch location",
|
||||
"Element was denied permission to fetch your location. Please allow location access in your browser settings.": "Element was denied permission to fetch your location. Please allow location access in your browser settings.",
|
||||
"Failed to fetch your location. Please try again later.": "Failed to fetch your location. Please try again later.",
|
||||
"Timed out trying to fetch your location. Please try again later.": "Timed out trying to fetch your location. Please try again later.",
|
||||
"Unknown error fetching location. Please try again later.": "Unknown error fetching location. Please try again later.",
|
||||
"Failed to load group members": "Failed to load group members",
|
||||
"Filter community members": "Filter community members",
|
||||
"Are you sure you want to remove '%(roomName)s' from %(groupId)s?": "Are you sure you want to remove '%(roomName)s' from %(groupId)s?",
|
||||
|
|
Loading…
Reference in a new issue