From 6cbdcfdcf296ef01419e712e333404c84a754a5e Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Mon, 4 Mar 2024 16:52:01 -0500 Subject: [PATCH] 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. --- .../AppLayouts/Chat/views/ChatColumnView.qml | 5 ++++ ui/app/AppLayouts/Chat/views/ChatView.qml | 26 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/ui/app/AppLayouts/Chat/views/ChatColumnView.qml b/ui/app/AppLayouts/Chat/views/ChatColumnView.qml index ef4d4895595..ea57f4a4895 100644 --- a/ui/app/AppLayouts/Chat/views/ChatColumnView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatColumnView.qml @@ -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.") } diff --git a/ui/app/AppLayouts/Chat/views/ChatView.qml b/ui/app/AppLayouts/Chat/views/ChatView.qml index d2be46dfa6f..16ae9d47ae7 100644 --- a/ui/app/AppLayouts/Chat/views/ChatView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatView.qml @@ -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