fix: fix token master can't send a message on permissioned channel

Fixes #13779

The problem was that the permission update some times takes time to get propagated and get back, or even the control node is offline, so the TM would not be able to post, because the backend would detect that there is a permission and that we don't have the key for it.

The solution is to block the UI when a permission update is pending, since we can't post correctly while it is not processed by he control node.
This commit is contained in:
Jonathan Rainville 2024-03-04 16:52:01 -05:00
parent 97b02e1f04
commit 6cbdcfdcf2
2 changed files with 31 additions and 0 deletions

View File

@ -45,6 +45,7 @@ Item {
property int chatsCount: parentModule && parentModule.model ? parentModule.model.count : 0
property int activeChatType: parentModule && parentModule.activeItem.type
property bool stickersLoaded: false
property bool permissionUpdatePending: false
property bool viewAndPostPermissionsSatisfied: true
property var viewAndPostHoldingsModel
@ -258,6 +259,7 @@ Item {
&& root.rootStore.sectionDetails.joined
&& !root.rootStore.sectionDetails.amIBanned
&& root.rootStore.isUserAllowedToSendMessage
&& !root.permissionUpdatePending
}
store: root.rootStore
@ -277,6 +279,9 @@ Item {
if (!root.rootStore.sectionDetails.joined || root.rootStore.sectionDetails.amIBanned) {
return qsTr("You need to join this community to send messages")
}
if (root.permissionUpdatePending) {
return qsTr("Some permissions are being updated. You will be able to send messages once the control node is back online.")
}
if (!root.viewAndPostPermissionsSatisfied) {
return qsTr("Sorry, you don't have permissions to post in this channel.")
}

View File

@ -10,6 +10,7 @@ import shared.status 1.0
import shared.stores 1.0
import shared.views.chat 1.0
import shared.stores.send 1.0
import SortFilterProxyModel 0.2
import StatusQ.Layout 0.1
import StatusQ.Popups 0.1
@ -19,6 +20,7 @@ import "."
import "../panels"
import AppLayouts.Communities.panels 1.0
import AppLayouts.Communities.views 1.0
import AppLayouts.Communities.controls 1.0
import AppLayouts.Wallet.stores 1.0 as WalletStore
import "../popups"
import "../helpers"
@ -58,6 +60,29 @@ StatusSectionLayout {
property var assetsModel
property var collectiblesModel
readonly property var pendingViewOnlyPermissionsModel: SortFilterProxyModel {
sourceModel: root.viewOnlyPermissionsModel
filters: [
ValueFilter {
roleName: "permissionState"
value: PermissionTypes.State.Approved
inverted: true
}
]
}
readonly property var pendingViewAndPostPermissionsModel: SortFilterProxyModel {
sourceModel: root.viewAndPostPermissionsModel
filters: [
ValueFilter {
roleName: "permissionState"
value: PermissionTypes.State.Approved
inverted: true
}
]
}
readonly property bool permissionUpdatePending: pendingViewOnlyPermissionsModel.count > 0 || pendingViewAndPostPermissionsModel.count > 0
readonly property bool contentLocked: {
if (!rootStore.chatCommunitySectionModule.isCommunity()) {
return false
@ -204,6 +229,7 @@ StatusSectionLayout {
stickersLoaded: root.stickersLoaded
emojiPopup: root.emojiPopup
stickersPopup: root.stickersPopup
permissionUpdatePending: root.permissionUpdatePending
viewAndPostHoldingsModel: root.viewAndPostPermissionsModel
viewAndPostPermissionsSatisfied: !root.rootStore.chatCommunitySectionModule.isCommunity() || root.viewAndPostPermissionsSatisfied
amISectionAdmin: root.amISectionAdmin