mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 15:06:20 +00:00
Split useTranslation into state + actions via useBetween singleton
Same pattern as the wired-tools split: 600-line useTranslation backs 6 consumers with a wide state + action surface. Split along the read/write seam: - useTranslationStore (internal, was the inner useTranslationState) — the previous singleton body, untouched except for the rename and a doc-comment. - useTranslationState (public, read-only) — useBetween filter exposing settings, the supported-languages list, the loading/loaded flags, the detected-language tags, lastError, and the pure getLanguageName helper. - useTranslationActions (public, imperative) — same singleton filter exposing updateSettings, ensureSupportedLanguagesLoaded, the four translate/queue helpers. Also re-exposes 'settings' because most call sites need 'if(settings.enabled)' before dispatching. - useTranslation (deprecated shim) — composes the singleton via useBetween, preserving the historical full-shape return. applyTextTranslationLocale stays exported from the same module path so LoginView's import keeps working. Updates docs/ARCHITECTURE.md proposal #4 section to list the three new splits (chat-input + wired-tools + translation) alongside the previous five.
This commit is contained in:
@@ -387,6 +387,24 @@ The current branch (**`feat/react19-modernization`**, PR #2) has applied:
|
||||
bridges + 1 derive effect) + `useFriendRequestActions` (thin
|
||||
adapter on the friends store) + shim. Exports `ActiveFriendRequest`
|
||||
type.
|
||||
- **chat input**: `useChatInputState` (5 state slices + 3 event
|
||||
listeners + 3 lifecycle effects: flood countdown, idle auto-clear,
|
||||
typing-indicator sync) + `useChatInputActions` (`sendChat` with
|
||||
the full slash-command repertoire and the outgoing-translation
|
||||
pipeline) + shim. Single consumer (`ChatInputView`) keeps the
|
||||
original tuple.
|
||||
- **wired tools**: `useWiredToolsStore` (internal singleton — state,
|
||||
listeners, effects, 13 actions in one closure) + `useWiredToolsState`
|
||||
/ `useWiredToolsActions` (read-only and imperative `useBetween`
|
||||
filters over the same singleton) + `useWiredTools` shim. Used by
|
||||
~20 consumers; the singleton sharing keeps a single source of
|
||||
truth while letting consumers import only the slice they touch.
|
||||
- **translation**: `useTranslationStore` (internal singleton) +
|
||||
`useTranslationState` / `useTranslationActions` (filtered
|
||||
`useBetween` views) + `useTranslation` shim. Same pattern as
|
||||
Wired tools — six consumers split across read-only views
|
||||
(settings panel, bootstrap) and dispatch sites (messenger, chat
|
||||
input).
|
||||
- **Zustand** (proposal #5) — **enabled**. `zustand` installed; factory at
|
||||
`src/state/createNitroStore.ts`. First adoption: the `let isCreatingRoom`
|
||||
/ `createRoomTimeout` module-level pair in `NavigatorRoomCreatorView`
|
||||
|
||||
Reference in New Issue
Block a user