Skip to content

fix(react): invoke handleLogout on channel access errors and add null guards in ChatHeader - #1428

Open
yashsarvaiya45 wants to merge 2 commits into
RocketChat:developfrom
yashsarvaiya45:fix/chatheader-incomplete-logout-state
Open

yashsarvaiya45 wants to merge 2 commits into
RocketChat:developfrom
yashsarvaiya45:fix/chatheader-incomplete-logout-state

Conversation

@yashsarvaiya45

Copy link
Copy Markdown
Contributor

Description

Fixes #1427

Updated error handling inside getChannelInfo and setMessageAllowed in ChatHeader.js:

  • Replaced direct RCInstance.logout() calls on 'error-room-not-found' and 'Not Allowed' errors with handleLogout() so that isUserAuthenticated is reset to false and user/channel/message stores are properly cleared.
  • Added try...catch blocks and safe optional chaining (res?.success, res && 'errorType' in res) in getChannelInfo and setMessageAllowed to prevent unhandled rejections or TypeError crashes on malformed/undefined API responses.
  • Updated useCallback and useEffect dependency arrays to resolve stale closure warnings.

Testing

  • Verified formatting with Prettier and confirmed all workspace lint checks pass (yarn lint).

This branch has not been deployed

No deployments
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: Incomplete logout leaves UI stuck in authenticated state when channel is missing or access is denied in ChatHeader.js

1 participant