Skip to content

Commit

Permalink
surface error when map info cannot be loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
achou11 committed Oct 21, 2024
1 parent ed0f9e4 commit 4215dff
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 19 deletions.
3 changes: 3 additions & 0 deletions messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,9 @@
"screens.Settings.MapManagement.BackgroundMaps.customMapAddedTitle": {
"message": "Custom Map Added"
},
"screens.Settings.MapManagement.BackgroundMaps.customMapInfoLoadError": {
"message": "Could not get custom map information. Please choose a different file."
},
"screens.Settings.MapManagement.BackgroundMaps.deleteCustomMapDescription": {
"message": "This will delete the map and its offline areas. No collected observation data will be deleted."
},
Expand Down
54 changes: 35 additions & 19 deletions src/frontend/screens/Settings/MapManagement/BackgroundMaps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '../../../hooks/server/maps';
import ErrorSvg from '../../../images/Error.svg';
import GreenCheckSvg from '../../../images/GreenCheck.svg';
import {DARK_GREY, WHITE} from '../../../lib/styles';
import {DARK_GREY, RED, WHITE} from '../../../lib/styles';
import {
BottomSheetModal,
BottomSheetModalContent,
Expand Down Expand Up @@ -46,6 +46,12 @@ const m = defineMessages({
'Your custom map is not shared with other devices in your project.',
},

customMapInfoLoadError: {
id: 'screens.Settings.MapManagement.BackgroundMaps.customMapInfoLoadError',
defaultMessage:
'Could not get custom map information. Please choose a different file.',
},

customMapAddedTitle: {
id: 'screens.Settings.MapManagement.BackgroundMaps.customMapAddedTitle',
defaultMessage: 'Custom Map Added',
Expand Down Expand Up @@ -116,26 +122,31 @@ export function BackgroundMapsScreen() {
case 'error': {
// TODO: Should surface error info better and also provide option to replace/remove map
renderedMapInfo = (
<ChooseMapFile
onChooseFile={() => {
selectCustomMapMutation.mutate(undefined, {
onSuccess: asset => {
if (!asset) return;
<>
<ChooseMapFile
onChooseFile={() => {
selectCustomMapMutation.mutate(undefined, {
onSuccess: asset => {
if (!asset) return;

return importCustomMapMutation.mutateAsync(
{
uri: asset.uri,
},
{
onSuccess: () => {
mapAddedBottomSheet.openSheet();
return importCustomMapMutation.mutateAsync(
{
uri: asset.uri,
},
},
);
},
});
}}
/>
{
onSuccess: () => {
mapAddedBottomSheet.openSheet();
},
},
);
},
});
}}
/>
<Text style={styles.infoLoadErrorText}>
{t(m.customMapInfoLoadError)}
</Text>
</>
);

break;
Expand Down Expand Up @@ -284,4 +295,9 @@ const styles = StyleSheet.create({
fontSize: 36,
color: DARK_GREY,
},
infoLoadErrorText: {
textAlign: 'center',
color: RED,
fontSize: 20,
},
});

0 comments on commit 4215dff

Please sign in to comment.