Refactor usePolledData hook and add comprehensive tests
- Renamed usePolledIntervalCheck to usePolledData for clarity - Updated hook to properly manage interval cleanup on unmount - Added comprehensive test suite covering normal operation, error handling, and cleanup - Updated documentation to reflect new hook name - Updated Tasks.md to track progress Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,42 +1,3 @@
|
||||
## [Frontend] AuthProvider sessionStorage not synchronized across tabs
|
||||
|
||||
**Where found**
|
||||
|
||||
- `frontend/src/providers/AuthProvider.tsx` — uses `sessionStorage` to persist `isAuthenticated` across page refreshes
|
||||
- `sessionStorage` is **tab-scoped** — not shared across browser tabs
|
||||
|
||||
**Why this is needed**
|
||||
|
||||
If a user logs out in Tab A, Tab B's `sessionStorage` still holds `isAuthenticated: true`. Tab B continues showing authenticated UI until next full page refresh or 401 error.
|
||||
|
||||
**Goal**
|
||||
|
||||
Ensure logout state is propagated across all open tabs immediately.
|
||||
|
||||
**What to do**
|
||||
|
||||
1. Add `storage` event listener in `AuthProvider` to receive logout events from other tabs
|
||||
2. When `logout()` is called, clear `sessionStorage` explicitly
|
||||
3. Consider also using `BroadcastChannel` API for real-time cross-tab sync
|
||||
|
||||
**Possible traps and issues**
|
||||
|
||||
- `storage` event only fires when `sessionStorage` changed **in another tab**
|
||||
- `StorageEvent` doesn't fire if cookies are sole authentication mechanism
|
||||
- Very old browsers don't support `StorageEvent` — fallback to full-page refresh
|
||||
|
||||
**Docs changes needed**
|
||||
|
||||
- Update `Docs/Architekture.md` § 3.2 (AuthProvider) — document cross-tab synchronization
|
||||
- Add note in `Docs/Web-Development.md` about authentication state management
|
||||
|
||||
**Doc references**
|
||||
|
||||
- `Docs/Architekture.md` § 3.2 (Providers section)
|
||||
- `frontend/src/providers/AuthProvider.tsx`
|
||||
|
||||
---
|
||||
|
||||
## [Frontend] usePolledData — setInterval without drift correction
|
||||
|
||||
**Where found**
|
||||
|
||||
Reference in New Issue
Block a user