Add real-time updates and fix delete button state

- 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
This commit is contained in:
2025-12-02 14:29:28 +00:00
parent 78901c8e2e
commit 0fc8c719b9
5 changed files with 77 additions and 49 deletions

View File

@@ -25,6 +25,7 @@ export default function DeleteItemButton({ itemId, listId, variant = 'full' }: D
try {
await deleteItem(itemId)
showToast('Task deleted successfully', 'success')
setShowConfirm(false)
if (listId) {
router.push(`/list/${listId}`)
} else {
@@ -33,6 +34,7 @@ export default function DeleteItemButton({ itemId, listId, variant = 'full' }: D
} catch (error) {
console.error('Error deleting item:', error)
showToast('Failed to delete task', 'error')
} finally {
setIsDeleting(false)
setShowConfirm(false)
}