Skip to content

Refactor: consolidate fragmented Zustand stores using slice pattern #1282

@sudorishabh

Description

@sudorishabh

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions