Skip to content

Conversation

@crspeller
Copy link
Member

Summary

Fixes MM-66699 where users encountered "Cannot read properties of undefined (reading 'username')" when sending their first message in the RHS.

Root Cause:
When the RHS is opened for the first time and a direct channel is created using Client4.createDirectChannel(), the user profiles are not automatically loaded into the Redux store. The Mattermost AdvancedTextEditor component requires access to state.entities.users.profiles[userId] to create posts, but this data was missing on first use.

Solution:
After creating the direct channel, we now:

  1. Fetch the current user profile using Client4.getMe()
  2. Fetch the bot user profile using Client4.getUser(botId)
  3. Dispatch RECEIVED_PROFILES action to add both profiles to Redux store

This ensures AdvancedTextEditor has access to the necessary user data when creating the first post.

Changes:

  • webapp/src/client.tsx: Export Client4 instance
  • webapp/src/components/rhs/rhs_new_tab.tsx: Load and dispatch user profiles after channel creation

Ticket Link

https://mattermost.atlassian.net/browse/MM-66699

Release Note

NONE

Fixes MM-66699 where users encountered "Cannot read properties of undefined
(reading 'username')" when sending their first message in the RHS.

Root Cause:
When the RHS is opened for the first time and a direct channel is created
using Client4.createDirectChannel(), the user profiles are not automatically
loaded into the Redux store. The Mattermost AdvancedTextEditor component
requires access to state.entities.users.profiles[userId] to create posts,
but this data was missing on first use.

Solution:
After creating the direct channel, we now:
1. Fetch the current user profile using Client4.getMe()
2. Fetch the bot user profile using Client4.getUser(botId)
3. Dispatch RECEIVED_PROFILES action to add both profiles to Redux store

This ensures AdvancedTextEditor has access to the necessary user data
when creating the first post.

Changes:
- webapp/src/client.tsx: Export Client4 instance
- webapp/src/components/rhs/rhs_new_tab.tsx: Load and dispatch user profiles
  after channel creation
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.

3 participants