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

[bug]: Issues with Read Only channel options #541

Closed umangutkarsh closed 1 week ago

umangutkarsh commented 3 months ago

Description:

Currently the following are the issues of 'read-only' channel.

  1. The read-only is not set dynamically to EC but is only set after page reload.
  2. The read-only is also set for admins which should not be the case.
  3. No appropriate message is displayed on EC when read-only option is toggled.

Steps to reproduce:

  1. Go to Rocket.Chat server
  2. Set to channel to read-only and see the behaviour.

Expected behavior:

The above mentioned issues should be resolved.

Actual behavior:

readonly.webm

devanshkansagra commented 1 week ago

Hey @umangutkarsh, I am currently working on this issue and I found another bug. that RCInstance.userInfo() does not working properly even if the user is logged in

image

output:

image

I have used currentUser from userStore(currentUser)

image

devanshkansagra commented 1 week ago

Hey I found an alternate way

const userRes = await RCInstance.getAuth();
const isAdmin = userRes.currentUser.me.roles.includes('admin');

this works

devanshkansagra commented 1 week ago

By this I solved the second point i.e, The read-only is also set for admins which should not be the case.

devanshkansagra commented 1 week ago

Now working on remaining 2 points

devanshkansagra commented 1 week ago

Hey @umangutkarsh, on changing the room to readonly in Rocket chat, it gives a warning in EC, I think due to that it preventing the dynamic reload

Warning is

Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.
    at ChatBody (http://localhost:6006/src_index_js.iframe.bundle.js:7190:3)
    at div
    at http://localhost:6006/vendors-node_modules_emotion_react_dist_emotion-react_browser_esm_js.iframe.bundle.js:1847:66
    at http://localhost:6006/src_components_Modal_index_js.iframe.bundle.js:158:3
    at http://localhost:6006/vendors-node_modules_emotion_react_dist_emotion-react_browser_esm_js.iframe.bundle.js:1847:66
    at div
    at http://localhost:6006/vendors-node_modules_emotion_react_dist_emotion-react_browser_esm_js.iframe.bundle.js:1847:66
    at http://localhost:6006/src_components_Modal_index_js.iframe.bundle.js:158:3
    at http://localhost:6006/vendors-node_modules_emotion_react_dist_emotion-react_browser_esm_js.iframe.bundle.js:1847:66
    at ChatLayout (http://localhost:6006/src_index_js.iframe.bundle.js:9251:71)
    at ToastBarProvider (http://localhost:6006/src_index_js.iframe.bundle.js:4362:3)
    at div
    at http://localhost:6006/vendors-node_modules_emotion_react_dist_emotion-react_browser_esm_js.iframe.bundle.js:1847:66
    at http://localhost:6006/src_components_Modal_index_js.iframe.bundle.js:158:3
    at http://localhost:6006/vendors-node_modules_emotion_react_dist_emotion-react_browser_esm_js.iframe.bundle.js:1847:66
    at ThemeProvider (http://localhost:6006/vendors-node_modules_emotion_react_dist_emotion-react_browser_esm_js.iframe.bundle.js:1886:64)
    at EmbeddedChat (http://localhost:6006/src_index_js.iframe.bundle.js:9868:3)
    at unboundStoryFn (http://localhost:6006/sb-preview/runtime.js:41:3330)
    at ErrorBoundary (http://localhost:6006/vendors-node_modules_storybook_addon-essentials_dist_actions_preview_mjs-node_modules_storybo-642a8b.iframe.bundle.js:1485:429) 
devanshkansagra commented 1 week ago

Could you please help me how to tackle this one?

Spiral-Memory commented 1 week ago

Hey @devanshkansagra

There are many issues with state updates in the application.. it's very difficult to find the exact cause of this issue specifically.

You try to debug it with console logs and figure out what might be causing it.. remove piece of code, understand it and try fixing it.

Also this issue has nothing to do with readonly channels.. in normal channels also, this warning is present

devanshkansagra commented 1 week ago

I have fixed the second point, just check it out

Screencast from 2024-06-26 12-08-54.webm

devanshkansagra commented 1 week ago

Hey @devanshkansagra

There are many issues with state updates in the application.. it's very difficult to find the exact cause of this issue specifically.

You try to debug it with console logs and figure out what might be causing it.. remove piece of code, understand it and try fixing it.

Also this issue has nothing to do with readonly channels.. in normal channels also, this warning is present

Hey @Spiral-Memory, could you please give an idea that how rocket.chat does this(the dynamic load), so that I can get reference and I can debug easily

Spiral-Memory commented 1 week ago

I'll suggest not doing it dynamically for now, there are many issues that need more attention than this.. however, it can be done, by studying the EmbeddedChat API, you will see a connect function there.. in that function we listen to realtime events.

You can specify the event there, and trigger a callback function to achieve it

devanshkansagra commented 1 week ago

Ok so do I push the second point of the issue?

Spiral-Memory commented 1 week ago

If you want to work on a good issue that I'm trying to fix for months.. let me know.. I'll tell you one

devanshkansagra commented 1 week ago

If you want to work on a good issue that I'm trying to fix for months.. let me know.. I'll tell you one

Yeah sure I am very excited and interested

devanshkansagra commented 1 week ago

Ok so do I push the second point of the issue?

It is solved so...

Spiral-Memory commented 1 week ago

Yep, raise your PR, I'll review it once ! Thanks a lot for your contribution 😊

Spiral-Memory commented 1 week ago

If you want to work on a good issue that I'm trying to fix for months.. let me know.. I'll tell you one

Yeah sure I am very excited and interested

Great, let me raise that issue for you !

devanshkansagra commented 1 week ago

Yea ok

devanshkansagra commented 1 week ago

I also found one issue, not regarding this but the different one

Spiral-Memory commented 1 week ago

Sure, do let me know that issue !

Spiral-Memory commented 1 week ago

Let's connect on open.rocket.chat, create an account there, and let me know your username, I'll DM you.. let's discuss regarding this there !

devanshkansagra commented 1 week ago

Yea, sure

devanshkansagra commented 1 week ago

If you want to work on a good issue that I'm trying to fix for months.. let me know.. I'll tell you one

Yeah sure I am very excited and interested

Great, let me raise that issue for you !

could you please do so that I can raise the PR

Spiral-Memory commented 1 week ago

If you want to work on a good issue that I'm trying to fix for months.. let me know.. I'll tell you one

Yeah sure I am very excited and interested

Great, let me raise that issue for you !

could you please do so that I can raise the PR

Don't be in a hurry about raising PRs.. that issue will take you some time to understand. Give it enough time to understand the issue, and see why this problem happens and how to fix it. I'm raising it right now.. please wait a little !

devanshkansagra commented 1 week ago

Ok

Spiral-Memory commented 1 week ago

Raised that issue ! Check it out

devanshkansagra commented 1 week ago

Hey here's my username of rocketchat: devansh.kansagra