1
1
/* eslint-disable react/destructuring-assignment */
2
2
// @ts -check
3
3
import * as React from 'react'
4
- import { Marker , Popup } from 'react-leaflet'
4
+ import { Circle , Marker , Popup } from 'react-leaflet'
5
5
6
6
import { useMarkerTimer } from '@hooks/useMarkerTimer'
7
- import { useMemory } from '@store/useMemory'
7
+ import { basicEqualFn , useMemory } from '@store/useMemory'
8
8
import { useStorage } from '@store/useStorage'
9
9
import { useForcePopup } from '@hooks/useForcePopup'
10
10
import { TooltipWrapper } from '@components/ToolTipWrapper'
@@ -21,11 +21,18 @@ const BaseStationTile = (station) => {
21
21
const [ stateChange , setStateChange ] = React . useState ( false )
22
22
const [ markerRef , setMarkerRef ] = React . useState ( null )
23
23
24
- const individualTimer = useMemory ( ( s ) => s . timerList . includes ( station . id ) )
24
+ const [ individualTimer , interactionRangeZoom ] = useMemory ( ( s ) => {
25
+ const { config, timerList } = s
26
+ return [ timerList . includes ( station . id ) , config . general . interactionRangeZoom ]
27
+ } , basicEqualFn )
25
28
26
- const showTimer = useStorage (
27
- ( s ) => s ?. userSettings ?. stations ?. stationTimers || individualTimer ,
28
- )
29
+ const [ showTimer , showInteractionRange ] = useStorage ( ( s ) => {
30
+ const { userSettings, zoom } = s
31
+ return [
32
+ userSettings . stations . stationTimers || individualTimer ,
33
+ ! ! userSettings . stations . interactionRanges && zoom >= interactionRangeZoom ,
34
+ ]
35
+ } , basicEqualFn )
29
36
30
37
const timers = React . useMemo ( ( ) => {
31
38
const now = Date . now ( ) / 1000
@@ -55,6 +62,14 @@ const BaseStationTile = (station) => {
55
62
{ ! ! ( showTimer && timers . length > 0 ) && (
56
63
< TooltipWrapper timers = { timers } offset = { [ 0 , 4 ] } />
57
64
) }
65
+ { showInteractionRange && (
66
+ < Circle
67
+ center = { [ station . lat , station . lon ] }
68
+ radius = { 80 }
69
+ color = "#EE94F7"
70
+ weight = { 0.5 }
71
+ />
72
+ ) }
58
73
</ Marker >
59
74
)
60
75
}
0 commit comments