Skip to content

Commit 8640704

Browse files
committed
fix: tailwind
1 parent ff444f1 commit 8640704

5 files changed

Lines changed: 26 additions & 5 deletions

File tree

.claude/settings.local.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
"Bash(ln:*)",
1313
"Bash(node scripts/sync-version.cjs:*)",
1414
"Bash(git rm:*)",
15-
"Bash(node:*)"
15+
"Bash(node:*)",
16+
"Bash(npm run build:*)",
17+
"Bash(timeout 10 npm run dev:*)",
18+
"Bash(npm run build:web:*)",
19+
"Bash(npm run build:desktop:*)"
1620
],
1721
"deny": [],
1822
"ask": []

packages/common/src/components/map/base.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export function BaseMap({ onMapLoaded, onCleanup }: { onMapLoaded?: (map: Map) =
7979
const sourceInitializedRef = useRef(false);
8080
const connectedStationsRef = useRef(new Set<string>());
8181

82-
const { data: rtsData, error: rtsError } = useRTS();
82+
const { data: rtsData, lastUpdate } = useRTS();
8383

8484
const [dataTime, setDataTime] = useState(0);
8585
const [maxIntensity, setMaxIntensity] = useState(-3);
@@ -88,6 +88,8 @@ export function BaseMap({ onMapLoaded, onCleanup }: { onMapLoaded?: (map: Map) =
8888
const [tooltipSwitchIndex, setTooltipSwitchIndex] = useState(0);
8989
const [tooltips, setTooltips] = useState<AlertTooltip[]>([]);
9090
const [alertStations, setAlertStations] = useState<AlertTooltip[]>([]);
91+
const [isStale, setIsStale] = useState(false);
92+
const lastReceivedTimeRef = useRef(0);
9193

9294
const formatTime = (ts: number) => {
9395
if (!ts) return '';
@@ -232,10 +234,21 @@ export function BaseMap({ onMapLoaded, onCleanup }: { onMapLoaded?: (map: Map) =
232234
};
233235
}, []);
234236

237+
// Check stale status on every update (triggered by RTSContext's 1s interval)
238+
useEffect(() => {
239+
if (lastUpdate === 0) return;
240+
const now = Date.now();
241+
if (lastReceivedTimeRef.current > 0) {
242+
setIsStale(now - lastReceivedTimeRef.current > 3000);
243+
}
244+
}, [lastUpdate]);
245+
235246
// Process RTS data when it updates
236247
useEffect(() => {
237248
if (!rtsData) return;
238249
setDataTime(rtsData.time);
250+
lastReceivedTimeRef.current = Date.now();
251+
setIsStale(false);
239252
let max = -3;
240253
const alerts: AlertTooltip[] = [];
241254
for (const f of rtsData.geojson.features) {
@@ -348,7 +361,7 @@ export function BaseMap({ onMapLoaded, onCleanup }: { onMapLoaded?: (map: Map) =
348361
</div>
349362
</div>
350363
<div className="bg-black/70 backdrop-blur-md rounded-lg px-3 py-1.5 border border-white/10 shadow-lg flex items-center gap-1.5">
351-
<div className={`w-2 h-2 rounded-full animate-pulse ${rtsError ? 'bg-red-500' : 'bg-emerald-400'}`} />
364+
<div className={`w-2 h-2 rounded-full animate-pulse ${isStale ? 'bg-red-500' : 'bg-emerald-400'}`} />
352365
<span className="text-white/90 text-xs font-medium tracking-wide">{formatTime(dataTime)}</span>
353366
</div>
354367
</div>

packages/common/src/contexts/RTSContext.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ interface RTSContextType {
88
data: ProcessedStationData | null;
99
isLoading: boolean;
1010
error: Error | null;
11+
lastUpdate: number;
1112
}
1213

1314
const RTSContext = createContext<RTSContextType | undefined>(undefined);
@@ -16,6 +17,7 @@ export function RTSProvider({ children }: { children: React.ReactNode }) {
1617
const [data, setData] = useState<ProcessedStationData | null>(null);
1718
const [isLoading, setIsLoading] = useState<boolean>(true);
1819
const [error, setError] = useState<Error | null>(null);
20+
const [lastUpdate, setLastUpdate] = useState<number>(0);
1921
const workerManagerRef = useRef<RTSWorkerManager | null>(null);
2022
const isMountedRef = useRef<boolean>(true);
2123

@@ -40,6 +42,7 @@ export function RTSProvider({ children }: { children: React.ReactNode }) {
4042
} finally {
4143
if (isMountedRef.current) {
4244
setIsLoading(false);
45+
setLastUpdate(Date.now());
4346
}
4447
}
4548
};
@@ -59,7 +62,7 @@ export function RTSProvider({ children }: { children: React.ReactNode }) {
5962
}, []);
6063

6164
return (
62-
<RTSContext.Provider value={{ data, isLoading, error }}>
65+
<RTSContext.Provider value={{ data, isLoading, error, lastUpdate }}>
6366
{children}
6467
</RTSContext.Provider>
6568
);

packages/desktop/src/app/globals.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import "tailwindcss";
2+
@source "../../../../packages/common/src/**/*.tsx";
23

34
:root {
45
--background: oklch(1.0000 0 0);

packages/web/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3-
import "./.next/dev/types/routes.d.ts";
3+
import "./.next/types/routes.d.ts";
44

55
// NOTE: This file should not be edited
66
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

0 commit comments

Comments
 (0)