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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user