Initialize chat only if user is logged in and it wasn't initialized before #2161

Closed
ssuprunenko wants to merge 2 commits from gitlab-mr-iid-894 into develop
Member
Resolves #394 and https://git.pleroma.social/pleroma/pleroma/issues/1080 Also resolves https://git.pleroma.social/pleroma/pleroma/issues/856 and https://git.pleroma.social/pleroma/pleroma/issues/1067
Member

can we also get rid of chatDisabled? BE already reports if chat support has been enabled or not somewhere else.

can we also get rid of `chatDisabled`? BE already reports if chat support has been enabled or not somewhere else.
Member

isn't this still being called elsewhere?

isn't this still being called elsewhere?
Author
Member

initializeSocket is called in 2 places:

That means we didn't have all checks in one place, so I added missing checks to api.js

`initializeSocket` is called in 2 places: - in [after_store.js](https://git.pleroma.social/pleroma/pleroma-fe/blob/develop/src/boot/after_store.js#L115) if chat is enabled - in [users.js](https://git.pleroma.social/pleroma/pleroma-fe/blob/develop/src/modules/users.js#L456) if user token is present That means we didn't have all checks in one place, so I added missing checks to `api.js`
Member

???

???
Author
Member

There is another setSocket in chat.js (see #1936). Afaik setSocket from api.js isn't called anywhere.

There is another `setSocket` in [chat.js](https://git.pleroma.social/pleroma/pleroma-fe/blob/develop/src/modules/chat.js#L11) (see https://git.pleroma.social/pleroma/pleroma-fe/pulls/1936). Afaik `setSocket` from `api.js` isn't called anywhere.
Author
Member

ah, I guess I didn't answer your question, sorry.

Ok, please correct me if I'm wrong:

  • store.state.chatDisabled is a frontend-only config option, defined in config.json
  • If chat is disabled on BE (config :pleroma, :chat, enabled: false), we are still trying to initialize socket and chat, then get 403 error, trying again and again... But the chat panel is hidden because of the errored state in App.js

So if we get rid of chatDisabled here, we will ignore frontend config. It has nothing with BE.

ah, I guess I didn't answer your question, sorry. Ok, please correct me if I'm wrong: - `store.state.chatDisabled` is a frontend-only config option, defined in [config.json](https://git.pleroma.social/pleroma/pleroma-fe/blob/develop/static/config.json#L9) - If chat is disabled on BE (`config :pleroma, :chat, enabled: false`), we are still trying to initialize socket and chat, then get 403 error, trying again and again... But the chat panel is hidden because of the `errored` state in [App.js](https://git.pleroma.social/pleroma/pleroma-fe/blob/develop/src/App.js#L90) So if we get rid of `chatDisabled` here, we will ignore frontend config. It has nothing with BE.
Member

i'm saying that frontend-only should go away, and instead we should check if BE has chat enabled or not.

i'm saying that frontend-only should go away, and instead we should check if BE has chat enabled or not.
Author
Member

According to @lambadalambda we are going to use socket not just for the chat, so I will return setSocket back to api.js

According to @lambadalambda we are going to use socket not just for the chat, so I will return `setSocket` back to api.js
Author
Member

I removed that frontend-only option and refactored things a bit

I removed that frontend-only option and refactored things a bit

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pleroma/pleroma-fe!2161
No description provided.