Skip to content

fix: reset isChannelPrivate when switching to a public room - #1

Closed
rohanesor wants to merge 4 commits into
developfrom
fix/1232-reset-is-channel-private
Closed

rohanesor wants to merge 4 commits into
developfrom
fix/1232-reset-is-channel-private

Conversation

@rohanesor

Copy link
Copy Markdown
Owner

fix: reset isChannelPrivate when switching to a public room

Acceptance Criteria fulfillment

  • Public rooms consistently use the channels.* endpoints, regardless of which room was opened before
  • The isChannelPrivate store flag reflects the current room instead of latching to true
  • Message history loads after visiting a private room and then a public one

Fixes RocketChat#1232

What changed

isChannelPrivate was only ever set on, never back off:

// useFetchChatData.js
if (channelIsPrivate) setIsChannelPrivate(true);
// ChatHeader.js
if (res.room.t === 'p') setIsChannelPrivate(true);

Once any private room was opened, the flag stayed true for the rest of the
session. Every later public room was then treated as private, so the callers
that read the flag from channelStore -- getOlderMessages,
getThreadMessages and getChannelMembers -- selected the groups.*
endpoints. For a public room such as GENERAL that produces
GET /api/v1/groups.messages?roomId=GENERAL -> 400 Bad Request, and the
history never loads, which is exactly the behaviour reported in RocketChat#1232.

Both sites now assign the actual room type:

setIsChannelPrivate(channelIsPrivate);          // useFetchChatData.js
setIsChannelPrivate(res.room.t === 'p');        // ChatHeader.js

Two lines, no refactors, no formatting changes.

Why this and not getMessages

useFetchChatData already computes a correct local channelIsPrivate and
passes it directly to getMessages, which is why the initial fetch can look
fine while paging, threads and member lookups still break. The defect is in the
shared store value, so that is what this fixes.

How it was tested

Repository CI (.github/workflows/build-and-lint.yml) reproduced locally on
Node 24 / yarn 3.6.4:

Command Result
yarn format:check pass, 10 projects
yarn lint pass, 6 projects, 0 errors
yarn build pass, 10 projects
yarn build:storybook pass, 2 projects

ESLint reports 30 warnings both with and without this change -- verified against
a clean checkout of develop at the same commit (8c542970), so this PR
introduces no new warnings.

No unit test is added: packages/react has no unit-test runner wired up (there
is no test script, and CI runs only format/lint/build), so there is no
existing harness to extend. Happy to add one if maintainers would like the
test tooling set up as part of this or a follow-up.

Video/Screenshots

Not applicable -- no visual change; this restores the message-history fetch.

PR Test Details

Steps from the issue:

  1. Run EmbeddedChat against a workspace with a public room (GENERAL) and a private room.
  2. Open the private room first, then switch to the public room.
  3. Before: groups.messages -> 400, history empty. After: channels.messages -> 200, history loads.

deepak0x and others added 4 commits October 10, 2026 17:11
…persistence

Persist draft messages per room across navigation
The channel-private flag was only ever latched to true and never reset,
so after visiting a private room the store kept reporting every
subsequent public room as private. Downstream callers
(getOlderMessages, getThreadMessages, getChannelMembers) then used the
groups.* endpoints for public rooms, which responds 400 and leaves the
message history empty.

Set the flag to the actual room type instead of only setting it on
private rooms.

Fixes RocketChat#1232
@rohanesor

Copy link
Copy Markdown
Owner Author

Recreating: the fork's develop was 3 commits behind upstream when this was opened, so the diff showed unrelated commits.

@rohanesor rohanesor closed this Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Message history fails to load

3 participants