status-im / status-desktop

Status Desktop client made in Nim & QML
https://status.app
Mozilla Public License 2.0
271 stars 76 forks source link

[Epic] Refactor community and channel permissions data transformation #14806

Open alexjba opened 1 month ago

alexjba commented 1 month ago

In a nutshell

Provide data models as they are received from status-go and move the transformation to the QML layer. Add a new API to fetch permissions data for an arbitrary account selection, with the lifetime of this data controlled by QML and synced with backend events.

Description

Overview

The current permissions model was initially designed to support a specific UI component aimed at displaying permission holdings criteria and verifying if these criteria are met by user account holdings. However, the tokenised communities UI has grown more complex, and the existing model structure no longer fits our needs. This epic focuses on refactoring the permissions model to accommodate new use cases and improve data handling and presentation.

Current Issue

The existing model only supports a specific use-case: verifying if user account holdings meet the criteria set by admins, using two RPCs (checkAllChannelsPermissions and checkPermissionsToJoin) to get the satisfied flag. However, this structure drops valuable data at the nim layer, which must be re-assembled at the UI layer, leading to inefficiencies and limitations.

Objectives

The primary goals are to support new use cases efficiently, provide the UI with correctly structured data, synchronize data between the nim and UI layers, and improve the model’s maintainability and scalability.

New Use Cases (difficult to adapt to current model structure)

The existing RPCs already provide the necessary data structured precisely for each new use case, but the current model fails to utilize this structured data effectively:

Member Role Determination: The checkPermissionsToJoin RPC provides the overall satisfied status and the highest role directly. This information is crucial for the join community flows, but the current model does not leverage this structured data.

Channel Permissions: The checkAllChannelsPermissions RPC returns data grouped by channels, exactly as needed for determining channel permissions. This is essential for join community flows and other chat functionalities. However, the current model discards this structured data, requiring unnecessary reassembly in the UI layer.

Holdings Criteria Display: Both checkPermissionsToJoin and checkAllChannelsPermissions RPCs return data grouped by role, with the token requirements provided. This structure is ideal for displaying all holdings criteria per role/channel permission in the join community flows. Unfortunately, the current model does not retain this organization, necessitating additional processing in the UI.

Data Scenarios:

The main difference in the data scenarios is the account selection used to compute the models and the models lifetime. These are the two models we currently have. Chat Section Model: Requires live data synced with holdings from shared addresses for determining channel permissions and initial join request permissions. This model lives as long as the chat section and it's correct. But the UI fails to maintain the synchronisation effectively for some of the new use cases described above. Community Model: Needs data requested on demand in the UI with arbitrary wallet account selection. This can be generated by using a different account selection as the Chat Section Model. The current implementation in the communities module is inadequate, as it can be overridden by another community’s info and is wrongly synchronised with the chat section permissions model (with a different account selection).

Proposal

To address these needs, the proposal is to change the current architecture based on the agreements made at the offsite meeting (https://miro.com/app/board/uXjVKS3chcc=/). The steps are as follows:

Tasks

alexjba commented 1 month ago

cc @noeliaSD @jrainville