Repository navigation
Conversation
…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
Owner
Author
|
Recreating: the fork's develop was 3 commits behind upstream when this was opened, so the diff showed unrelated commits. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: reset
isChannelPrivatewhen switching to a public roomAcceptance Criteria fulfillment
channels.*endpoints, regardless of which room was opened beforeisChannelPrivatestore flag reflects the current room instead of latching totrueFixes RocketChat#1232
What changed
isChannelPrivatewas only ever set on, never back off:Once any private room was opened, the flag stayed
truefor the rest of thesession. Every later public room was then treated as private, so the callers
that read the flag from
channelStore--getOlderMessages,getThreadMessagesandgetChannelMembers-- selected thegroups.*endpoints. For a public room such as
GENERALthat producesGET /api/v1/groups.messages?roomId=GENERAL->400 Bad Request, and thehistory never loads, which is exactly the behaviour reported in RocketChat#1232.
Both sites now assign the actual room type:
Two lines, no refactors, no formatting changes.
Why this and not
getMessagesuseFetchChatDataalready computes a correct localchannelIsPrivateandpasses it directly to
getMessages, which is why the initial fetch can lookfine 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 onNode 24 / yarn 3.6.4:
yarn format:checkyarn lintyarn buildyarn build:storybookESLint reports 30 warnings both with and without this change -- verified against
a clean checkout of
developat the same commit (8c542970), so this PRintroduces no new warnings.
No unit test is added:
packages/reacthas no unit-test runner wired up (thereis no
testscript, and CI runs only format/lint/build), so there is noexisting 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:
GENERAL) and a private room.groups.messages-> 400, history empty. After:channels.messages-> 200, history loads.