Skip to content

Commit 3d72e14

Browse files
committed
fix: station display
1 parent 74c2d5c commit 3d72e14

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

src/features/station/StationTile.jsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,26 @@ const BaseStationTile = (station) => {
3838
]
3939
}, basicEqualFn)
4040

41+
const { start_time, battle_end, end_time } = station
42+
4143
const timers = React.useMemo(() => {
4244
const now = Date.now() / 1000
4345
const internalTimers = /** @type {number[]} */ ([])
4446
if (showTimer) {
45-
const hasStart = Number.isFinite(station.start_time)
46-
const hasBattleEnd = Number.isFinite(station.battle_end)
47-
const hasEnd = Number.isFinite(station.end_time)
47+
const hasStart = Number.isFinite(start_time)
48+
const hasBattleEnd = Number.isFinite(battle_end)
49+
const hasEnd = Number.isFinite(end_time)
4850

49-
if (hasStart && station.start_time > now) {
50-
internalTimers.push(station.start_time)
51-
} else if (hasBattleEnd && station.battle_end > now) {
52-
internalTimers.push(station.battle_end)
53-
} else if (hasEnd && station.end_time > now) {
54-
internalTimers.push(station.end_time)
51+
if (hasStart && start_time > now) {
52+
internalTimers.push(start_time)
53+
} else if (hasBattleEnd && battle_end > now) {
54+
internalTimers.push(battle_end)
55+
} else if (hasEnd && end_time > now) {
56+
internalTimers.push(end_time)
5557
}
5658
}
5759
return internalTimers
58-
}, [showTimer])
60+
}, [showTimer, start_time, battle_end, end_time])
5961

6062
useForcePopup(station.id, markerRef)
6163
useMarkerTimer(timers.length ? Math.min(...timers) : null, markerRef, () =>

src/features/station/useStationMarker.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export function useStationMarker({
2525
const now = Date.now() / 1000
2626
const isInactive = Number.isFinite(end_time) && end_time < now
2727
const hasStarted = Number.isFinite(start_time) && start_time < now
28+
const isBattleActive = Number.isFinite(battle_end) && battle_end > now
2829
const [, Icons] = useStorage(
2930
(s) => [s.icons, useMemory.getState().Icons],
3031
(a, b) => Object.entries(a[0]).every(([k, v]) => b[0][k] === v),
@@ -53,17 +54,13 @@ export function useStationMarker({
5354
const [stationMod, battleMod] = Icons.getModifiers('station', 'dynamax')
5455
const getOpacity = useOpacity('stations')
5556
const stationOpacity = isInactive ? 0.3 : getOpacity(end_time)
56-
const battleOpacity = getOpacity(battle_end)
57-
const isActive =
58-
!isInactive &&
59-
!!battle_pokemon_id &&
60-
Number.isFinite(start_time) &&
61-
start_time < now
57+
const showBattleIcon =
58+
!isInactive && !!battle_pokemon_id && hasStarted && isBattleActive
6259

6360
return divIcon({
6461
popupAnchor: [
6562
0 + stationMod.popupX + stationMod.offsetX,
66-
(-baseSize - (isActive ? battleSize : 0)) * 0.67 +
63+
(-baseSize - (showBattleIcon ? battleSize : 0)) * 0.67 +
6764
stationMod.popupY +
6865
stationMod.offsetY +
6966
(-5 + battleMod.offsetY + battleMod.popupY),
@@ -84,13 +81,13 @@ export function useStationMarker({
8481
"
8582
/>
8683
${
87-
isActive
84+
showBattleIcon
8885
? /* html */ `
8986
<img
9087
src="${battleIcon}"
9188
alt="${battleIcon}"
9289
style="
93-
opacity: ${battleOpacity};
90+
opacity: ${getOpacity(battle_end)};
9491
width: ${battleSize}px;
9592
height: ${battleSize}px;
9693
bottom: ${baseSize * 0.8 * battleMod.offsetY}px;

0 commit comments

Comments
 (0)