From 5ae06ef0fec6c90dac06e2da4b450763af737cf1 Mon Sep 17 00:00:00 2001 From: Amaury Martiny Date: Sat, 10 Aug 2019 11:32:28 +0200 Subject: [PATCH] fix: Fix bugs with "Not saving" on startup and no reverse location name (#164) * Fix bug station too far on initial load * Don't show erronous location names --- App/stores/api.tsx | 1 + App/stores/fetchGpsPosition/fetchGpsPosition.ts | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/App/stores/api.tsx b/App/stores/api.tsx index d6162781..b0fac422 100644 --- a/App/stores/api.tsx +++ b/App/stores/api.tsx @@ -57,6 +57,7 @@ export function ApiContextProvider ({ children }: ApiContextProviderProps) { isGps ? pipe( saveApi(currentLocation, newApi), + TE.orElse(() => TE.right(undefined as void)), // Silently ignore if saveApi fails TE.map(() => newApi) ) : TE.right(newApi) diff --git a/App/stores/fetchGpsPosition/fetchGpsPosition.ts b/App/stores/fetchGpsPosition/fetchGpsPosition.ts index 570393fc..13a003a5 100644 --- a/App/stores/fetchGpsPosition/fetchGpsPosition.ts +++ b/App/stores/fetchGpsPosition/fetchGpsPosition.ts @@ -54,7 +54,12 @@ export function fetchReverseGeocode (currentLocation: LatLng) { ...currentLocation, city: reverse.city, country: reverse.country, - name: [reverse.street, reverse.city, reverse.country].join(', ') + name: + [reverse.street, reverse.city, reverse.country] + .filter(x => x) + .join(', ') || + // This case happens when e.g. we're in the middle of the ocean + [reverse.name, reverse.country].filter(x => x).join(', ') } as Location) ) );