Skip to content

Commit 1852c48

Browse files
cj-vanaclaude
andcommitted
Fix observer online status and add map auto-refresh
- Await updateObserverLastSeen() before fetching nodes (fixes first refresh showing offline) - Add 30-second auto-refresh to NetworkMap component 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f7c3be0 commit 1852c48

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/app/api/nodes/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export const revalidate = 0;
3333
*/
3434
export async function GET() {
3535
try {
36-
// Update observer last_seen before fetching (fire and forget)
37-
updateObserverLastSeen();
36+
// Update observer last_seen before fetching
37+
await updateObserverLastSeen();
3838

3939
const nodes = await getNodesWithStats();
4040

src/components/NetworkMap.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { MapContainer, TileLayer, Marker, Popup } from 'react-leaflet';
55
import L from 'leaflet';
66
import 'leaflet/dist/leaflet.css';
77
import type { NodeWithStats } from '@/lib/types';
8-
import { MAP_VISIBILITY_THRESHOLD_MS } from '@/lib/constants';
8+
import { MAP_VISIBILITY_THRESHOLD_MS, OBSERVER_REFRESH_INTERVAL } from '@/lib/constants';
99

1010
// Fix for default marker icons in Next.js - only run on client
1111
if (typeof window !== 'undefined') {
@@ -124,7 +124,12 @@ export function NetworkMap({ nodes, className = '' }: NetworkMapProps) {
124124
}
125125
}
126126

127+
// Initial fetch
127128
fetchNodes();
129+
130+
// Auto-refresh every 30 seconds
131+
const interval = setInterval(fetchNodes, OBSERVER_REFRESH_INTERVAL);
132+
return () => clearInterval(interval);
128133
}, [nodes]);
129134

130135
// Filter nodes with valid coordinates AND seen within 24 hours

0 commit comments

Comments
 (0)