- Simplified useRealtimeSync to use router.refresh() polling - Created RealtimeUpdater component for easy integration - Added real-time updates to home page (3s polling) - Fixed DeleteItemButton to properly reset state on error - Updates now refresh every 3 seconds and on window focus - Changes from other users/browsers will appear quickly
23 lines
462 B
TypeScript
23 lines
462 B
TypeScript
'use client'
|
|
|
|
import { useRealtimeSync } from '@/hooks/useRealtimeSync'
|
|
|
|
interface RealtimeUpdaterProps {
|
|
listId?: string
|
|
pollInterval?: number
|
|
}
|
|
|
|
/**
|
|
* Component that enables real-time updates for a page
|
|
* Just include this component and it will poll for updates
|
|
*/
|
|
export default function RealtimeUpdater({ listId, pollInterval = 3000 }: RealtimeUpdaterProps) {
|
|
useRealtimeSync({
|
|
listId,
|
|
enabled: true,
|
|
pollInterval,
|
|
})
|
|
|
|
return null
|
|
}
|