RocketChat / RocketChat/EmbeddedChat
Refactor: consolidate fragmented Zustand stores using slice pattern
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 165
- Forks
- 381
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 1
Description
Problem
The React package currently uses Zustand with multiple tiny stores (e.g. sidebarStore, pinnedMessageStore, searchMessageStore, fileStore, etc.). Many of these are single-boolean + setter stores and require importing/subscribing to many stores in central components.
This “store fragmentation” makes cross-panel logic harder (e.g. opening one panel should close others) and increases maintenance overhead.
Proposed improvement
Adopt a slice / consolidated-store approach in @embeddedchat/react:
- Group all sidebar/panel visibility flags into a single store (useChatLayoutStore) with an openExclusivePanel(panelKey) API.
- Group chat “meta/data” (starting with starred messages) into a single store (useChatDataStore).
- Consolidate auth modal state (isLoginIn, isLoginModalOpen, isTotpModalOpen) into one auth store (useAuthStore).
Acceptance criteria
- No remaining imports/usages of removed stores/hook.
- Sidebar panel toggling remains exclusive and behavior-preserving.
- Auth modals and login loading state work as before.
- Starred messages continue to load and render correctly.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the @embeddedchat/react package by locating sidebarStore, pinnedMessageStore, searchMessageStore, fileStore, and the auth and starred-message stores, then trace their imports and usages. Consolidate the specified state while preserving exclusive sidebar behavior, auth modal and loading behavior, and starred-message loading and rendering; verify that no removed store or hook usages remain.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100