RocketChat / RocketChat/EmbeddedChat

Refactor: consolidate fragmented Zustand stores using slice pattern

Open
#1,282 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.