Comments (3)
@abhinavkrin, I believe the issue lies in the execution order of the getChannelInfo
or getCurrentUser
function with respect to whether the currentUser
or currentUser.authToken
has been set. Upon refreshing, before currentUser is set, it sends a request to the backend to obtain the userId
and authToken
using const { userId, authToken } = await this.auth.getCurrentUser() || {};.
The function runs before the currentUser
or currentUser.authToken
is set, causing both variables to return undefined. Consequently, it sends a request to the Rocket Chat REST API with undefined information, leading to the inability to fetch the required data upon refresh. I would like to address this issue, but I am unsure how to fix the order of execution. Could you please guide me on this so that I can begin working on it?
I have debugged the issue, and here are my findings:
Console logs on refresh:
In RocketChatAuth.ts, I used the getCurrentUser() function to debug the issue:
from embeddedchat.
After debugging, I found that in the EmbeddedChat.js
frontend file, the isUserAuthenticated
variable was being set to true before successfully connecting to the RCInstance
. This premature setting caused a state change, triggering the execution of the useEffect
hook which runs getChannelInfo()
function in ChatHeader.js
. Since this function requires user information to fetch data which is not available as of now, it sent undefined credentials to the REST API backend, resulting in an error response and the inability to retrieve channel information.
To fix this, I modified the code so that isUserAuthenticated
changes to true only after a successful connection is established. This ensures that this.currentUser
is properly set on the backend, allowing for correct functionality upon refresh. I've submitted a pull request for your review, checking if my changes are correct.
from embeddedchat.
Thanks @Spiral-Memory for the investigation. 💯
from embeddedchat.
Related Issues (20)
- Implement UIKit Modal Support in EmbeddedChat HOT 6
- Global Context Provider for EmbeddedChat HOT 1
- Align invitation sidebar UI with RocketChat HOT 2
- Feat: Add a 'Files' menu option view the files shared in the channel HOT 4
- Add tooltips to message toolbox HOT 2
- Add download function and file name to messages attachments HOT 1
- Video & image attachments not correctly displayed HOT 4
- [BUG]: Link preview is not available. HOT 2
- Make search tab behavior consistent with threads & RC
- Change starred and pinned message windows to sidebar HOT 13
- Blank appearance of the message list after filtering pinned or starred messages (when no message is pinned or starred) HOT 1
- [BUG] Infinite render of search message component
- Refactor menu components HOT 3
- Irregular positioning and appearance of the tooltip component
- Cannot login EmbeddedChat through username and password HOT 5
- [Feature Request] Add a "Scroll to Top" button in EmbeddedChat
- MessageBox is Not Responsive for Minimize mode HOT 5
- [BUG]: No Fallback Icon in file menu when media type doesn't support preview
- Channel Members' Roles getting fetched using useUserStore
- [Feature Request] Pin icon should not be visible to users without pin permissions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from embeddedchat.