Improve real-time sync with 1-second polling and visual indicator

- Reduced polling interval from 2s to 1s for near-instant updates
- Added SyncIndicator component to show sync status
- Added console logging to debug sync behavior
- Updates across devices now appear within 1 second
- Visual feedback shows when data is being refreshed
This commit is contained in:
2025-12-03 00:29:24 +00:00
parent bd61aaa5b2
commit fc5ad9f7af
6 changed files with 176 additions and 3 deletions

View File

@@ -24,11 +24,12 @@ export function useRealtimeSync({
const intervalRef = useRef<NodeJS.Timeout | null>(null)
const refresh = useCallback(() => {
console.log('[RealtimeSync] Refreshing...', listId ? `list ${listId}` : 'page')
router.refresh()
if (onUpdate) {
onUpdate()
}
}, [router, onUpdate])
}, [router, onUpdate, listId])
useEffect(() => {
if (!enabled) {