Skip to content

Commit 7b7d1cc

Browse files
committed
now stop pos watching possible via button (if in-synch state)
1 parent fbb0e05 commit 7b7d1cc

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/map/LocationButton.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import styles from './LocationButton.module.css'
22
import Dispatcher from '@/stores/Dispatcher'
3-
import { StartSyncCurrentLocation, StartWatchCurrentLocation } from '@/actions/Actions'
3+
import {StartSyncCurrentLocation, StartWatchCurrentLocation, StopWatchCurrentLocation} from '@/actions/Actions'
44
import LocationError from '@/map/location_error.svg'
55
import LocationSearching from '@/map/location_searching.svg'
66
import LocationOn from '@/map/location_on.svg'
@@ -32,11 +32,14 @@ export default function LocationButton(props: { currentLocation: CurrentLocation
3232
<div
3333
className={styles.locationOnOff}
3434
onClick={() => {
35-
if (props.currentLocation.enabled && !props.currentLocation.error) {
35+
if (props.currentLocation.enabled && !props.currentLocation.syncView && !props.currentLocation.error) {
3636
Dispatcher.dispatch(new StartSyncCurrentLocation())
3737
} else {
38-
Dispatcher.dispatch(new StartWatchCurrentLocation())
39-
setLocationSearch('search')
38+
if (props.currentLocation.enabled) {
39+
Dispatcher.dispatch(new StopWatchCurrentLocation())
40+
} else {
41+
Dispatcher.dispatch(new StartWatchCurrentLocation())
42+
}
4043
}
4144
}}
4245
>

src/stores/CurrentLocationStore.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export default class CurrentLocationStore extends Store<CurrentLocationStoreStat
4848
coordinate: null,
4949
}
5050
} else if (action instanceof StopWatchCurrentLocation) {
51-
// TODO NOW stop location watching e.g. when pressing the location button once again if it shows 'success'
5251
this.stop()
5352
return {
5453
...state,

0 commit comments

Comments
 (0)