Skip to content

Commit

Permalink
fix: fix token master can't send a message on permissioned channel
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jrainville committed Mar 8, 2024
1 parent 97b02e1 commit 6cbdcfd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ui/app/AppLayouts/Chat/views/ChatColumnView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -258,6 +259,7 @@ Item {
&& root.rootStore.sectionDetails.joined
&& !root.rootStore.sectionDetails.amIBanned
&& root.rootStore.isUserAllowedToSendMessage
&& !root.permissionUpdatePending
}

store: root.rootStore
Expand All @@ -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.")
}
Expand Down
26 changes: 26 additions & 0 deletions ui/app/AppLayouts/Chat/views/ChatView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6cbdcfd

Please sign in to comment.