mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 15:06:20 +00:00
Split useNotification into state + actions via useBetween singleton
useNotification is consumed by ~44 sites in the codebase but most of them only need a single imperative entry point (typically simpleAlert or showConfirm). The hook also runs ~24 useMessageEvent listeners internally to translate server events into queued notifications. Same singleton-filter pattern as useWiredTools / useTranslation: - useNotificationStore (internal, was useNotificationState) — the previous body unchanged. ~30 listeners + 5 state slices + 8 actions in one closure. - useNotificationState (public, read-only) — useBetween filter exposing only the three queue arrays (alerts, bubbleAlerts, confirms). Used by the global NotificationView renderer. - useNotificationActions (public, imperative) — useBetween filter exposing the 8 entry points: simpleAlert / showNitroAlert / showTradeAlert / showConfirm / showSingleBubble + closeAlert / closeBubbleAlert / closeConfirm. - useNotification (deprecated shim) — composes the singleton via useBetween, preserving the historical return shape so the 44 existing call sites keep working. Also brings CLAUDE.md's 'What's wired up' table up to date with the splits done this session (chat-input doorbell-style, wired-tools + translation singleton-filter, plus this notification one) and the 8 useCatalog fetch migrations to TanStack queries.
This commit is contained in:
@@ -155,19 +155,20 @@ Login / Register / Forgot in `src/components/login/LoginView.tsx` use
|
||||
|
||||
| Adopted | Pilot sites |
|
||||
|---|---|
|
||||
| `useNitroEventState` | `OfferView` |
|
||||
| `useNitroQuery` | `OfferView`, `CatalogLayoutRoomAdsView`, `ModToolsChatlogView`, `CfhChatlogView` |
|
||||
| `useNitroEventState` + companions (Reducer, ExternalSnapshot) | `OfferView`, `useAvatarInfoWidget` (figure/badges/group reducer), `useInventoryFurni` (pure reducers + fragments useRef) |
|
||||
| `useNitroQuery` + `useNitroEventInvalidator` | `OfferView`, `CatalogLayoutRoomAdsView`, `ModToolsChatlogView`, `CfhChatlogView`, `useGiftConfiguration`, `useUserGroups`, `useClubOffers(windowId)`, `useSellablePetPalette(breed)`, `useMarketplaceConfiguration`, `useClubGifts` (with invalidator) |
|
||||
| Zustand | `NavigatorRoomCreatorView` (`useRoomCreatorStore`) |
|
||||
| God-hook split | `doorbell`, `poll`, `furni-chooser`, `user-chooser`, `friend-request` |
|
||||
| God-hook split (state + actions + shim) | `doorbell`, `poll`, `furni-chooser`, `user-chooser`, `friend-request`, `chat-input` |
|
||||
| God-hook split (`useBetween` singleton + state filter + actions filter + shim) | `wired-tools`, `translation` |
|
||||
| `WidgetErrorBoundary` | `RoomWidgetsView` umbrella |
|
||||
| Vitest | 99/99 cases on pure helpers + the Zustand store |
|
||||
|
||||
| Not yet | Notes |
|
||||
|---|---|
|
||||
| Split `useCatalog` (~1100 LOC) | Migrate read-only fetches to `useNitroQuery` first, then split into `useCatalogData` / `useCatalogUiState` / `useCatalogActions`. |
|
||||
| Split `useChatInputWidget` / `useChatWidget` / `useAvatarInfoWidget` | Large state machines; needs careful per-file design before mechanical split. |
|
||||
| Split `usePetPackageWidget` / `useWordQuizWidget` | Their "actions" mutate internal state; need to either pass args or hoist state to a store first. Documented in commit messages, skipped intentionally. |
|
||||
| Hoist Wired Creator Tools shared state to a Zustand slice | Would remove ~25 props passed to the 3 tab sub-components. |
|
||||
| Core `useCatalog` split | Session-stable secondary fetches all migrated to TanStack queries (see ARCHITECTURE.md). What's left: core `rootNode`/`offersToNodes`/`currentPage` slice + Builders Club status. Needs a dedicated `useCatalogData`/`useCatalogUiState`/`useCatalogActions` split. |
|
||||
| Split `useChatWidget` / `useAvatarInfoWidget` | Both state-driven via events with no clean imperative actions to extract — skip-motivated. Already touched today for the InfoStand listener move. |
|
||||
| Split `usePetPackageWidget` / `useWordQuizWidget` / `useChatCommandSelector` | Their "actions" mutate internal state or are tightly interdependent — skip-motivated. |
|
||||
| Hoist Wired Creator Tools shared state to a Zustand slice | Would remove ~25 props passed to the 3 tab sub-components. (Wired-tools split done as singleton-filter; Zustand slice is the next step.) |
|
||||
| Wider Vitest coverage (React components) | `@testing-library/*` is installed; needs a small renderer-SDK mock layer first. |
|
||||
|
||||
## Known open logic bugs
|
||||
|
||||
Reference in New Issue
Block a user