RocketChat / EmbeddedChat

An easy to use full-stack component (ReactJS) embedding Rocket.Chat into your webapp

Home Page:https://www.npmjs.com/package/@embeddedchat/react

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Channel Members' Roles getting fetched using useUserStore

thesynthax opened this issue · comments

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.