diff --git a/src/hooks/useLocationStore.ts b/src/hooks/useLocationStore.ts index b050f7a0a..cfc48da6a 100644 --- a/src/hooks/useLocationStore.ts +++ b/src/hooks/useLocationStore.ts @@ -7,3 +7,12 @@ export const useLocationStore = create( export const setLocation = (location: Location.LocationObject) => useLocationStore.setState(location) + +export const setLatLon = (latitude: number, longitude: number) => + useLocationStore.setState((prev) => { + if (!prev) { + return null + } + + return { ...prev, coords: { ...prev.coords, latitude, longitude } } + }) diff --git a/src/screens/FakeStationSettingsScreen.tsx b/src/screens/FakeStationSettingsScreen.tsx index f22047f06..bee9670af 100644 --- a/src/screens/FakeStationSettingsScreen.tsx +++ b/src/screens/FakeStationSettingsScreen.tsx @@ -30,7 +30,7 @@ import Heading from '../components/Heading' import { StationList } from '../components/StationList' import { FONTS } from '../constants' import { useCurrentStation } from '../hooks/useCurrentStation' -import { useLocationStore } from '../hooks/useLocationStore' +import { setLatLon, useLocationStore } from '../hooks/useLocationStore' import { useThemeStore } from '../hooks/useThemeStore' import { grpcClient } from '../lib/grpc' import { APP_THEME } from '../models/Theme' @@ -174,6 +174,7 @@ const FakeStationSettingsScreen: React.FC = () => { ...prev, stationForHeader: station, })) + setLatLon(station.latitude, station.longitude) onPressBack() }, [foundStations, onPressBack, setNavigationState, setStationState]