Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove calls to status-go when handling a community #19108

Closed
cammellos opened this issue Mar 5, 2024 · 1 comment
Closed

Remove calls to status-go when handling a community #19108

cammellos opened this issue Mar 5, 2024 · 1 comment

Comments

@cammellos
Copy link
Contributor

Description

:fx [[:dispatch [:communities/initialize-permission-addresses id]]

This code is run every time status-go signals the client of a community.

You can see that it will ask back status-go for extra information:

                              :fx [[:dispatch [:communities/initialize-permission-addresses id]]
            (when (not joined)
              [:dispatch [:chat.ui/spectate-community id]])
            (when (nil? token-permissions-check)
              [:dispatch [:communities/check-permissions-to-join-community id]])
            (when (some has-channel-perm? token-permissions)
              [:dispatch [:communities/check-all-community-channels-permissions id]])
            (when joined
              [:dispatch [:communities/get-revealed-accounts id]])]})))

This is generally a pattern we want to avoid, as in most cases, if there's any action to be performed, status-go should take care of that before passing it to the client.
Another issue is that it might create cycles, as this is called in response to RPC, but makes RPC calls, in this case it's handled by checking whether spectated/spectating is set, but it's fragile.

To start with, I think we should focus on removing spectating from a reaction to a status-go signal.
We should spectate a community only when we open a page of a community, not in response to any not-joined community in status-go.

Secondly, we should remove all the permisions checks. We should make those only when a user opens a community page.
And maybe we can discuss how to keep that page up to date, whether periodically, or by only checking permissions for that community that the user is on.

@ilmotta
Copy link
Contributor

ilmotta commented Feb 26, 2025

Closing as this tech debt is resolved. We now initialize permission addresses from a use-mount from the account selection component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

2 participants