RocketChat / EmbeddedChat

An easy to use full-stack component (ReactJS) embedding Rocket.Chat into your webapp
https://www.npmjs.com/package/@embeddedchat/react
107 stars 214 forks source link

Channel Members' Roles getting fetched using useUserStore #517

Closed thesynthax closed 2 months ago

thesynthax commented 3 months ago

Description:

While working on a feature requiring fetching the current user's roles in MessageToolbox.js (image 2, 4), I encountered a bug while console logging (image 1) the roles object that it was getting overwritten by some other function. After finding out which function was responsible, I saw that useFetchChatData.js was fetching channel members' roles and storing it in UserStore, which is specific to each user. useFetchChatData should instead use ChannelStore to store channel members' roles as the rolesObj contains roles information for all multiple users (image 3).

Expected behavior:

While console logging, the roles object should not be empty unlike in image 1.

Actual behavior:

ss_139 ss_140 ss_141 ss_142

Solution:

ChannelStore must contain a variable for storing members' roles and UserStore should not be used for this purpose.

I will be raising a PR fixing this bug.