fix(Communities): Show channel for non-members when read-only, tokenless permission is set

When channel has view-only permission not requiring any holdings, the
channel is not encrypted and should be presented to non-members in
read-only mode.

Closes: #14439
This commit is contained in:
Michał Cieślak 2024-05-17 11:06:31 +02:00 committed by Michał
parent 93d808d020
commit d2f73cd88f
2 changed files with 44 additions and 0 deletions

View File

@ -155,6 +155,44 @@ StackLayout {
root.sectionItemModel.memberRole === Constants.memberRole.admin ||
root.sectionItemModel.memberRole === Constants.memberRole.tokenMaster
hasViewOnlyPermissions: root.permissionsStore.viewOnlyPermissionsModel.count > 0
hasUnrestrictedViewOnlyPermission: {
viewOnlyUnrestrictedPermissionHelper.revision
const model = root.permissionsStore.viewOnlyPermissionsModel
const count = model.rowCount()
for (let i = 0; i < count; i++) {
const holdings = ModelUtils.get(model, i, "holdingsListModel")
if (holdings.rowCount() === 0)
return true
}
return false
}
Instantiator {
id: viewOnlyUnrestrictedPermissionHelper
model: root.permissionsStore.viewOnlyPermissionsModel
property int revision: 0
delegate: QObject {
ModelChangeTracker {
model: model.holdingsListModel
onRevisionChanged: viewOnlyUnrestrictedPermissionHelper.revision++
}
}
}
ModelChangeTracker {
model: root.permissionsStore.viewOnlyPermissionsModel
onRevisionChanged: viewOnlyUnrestrictedPermissionHelper.revision++
}
hasViewAndPostPermissions: root.permissionsStore.viewAndPostPermissionsModel.count > 0
viewOnlyPermissionsModel: root.permissionsStore.viewOnlyPermissionsModel
viewAndPostPermissionsModel: root.permissionsStore.viewAndPostPermissionsModel

View File

@ -51,7 +51,10 @@ StatusSectionLayout {
readonly property var chatContentModule: rootStore.currentChatContentModule() || null
readonly property bool viewOnlyPermissionsSatisfied: chatContentModule.viewOnlyPermissionsSatisfied
readonly property bool viewAndPostPermissionsSatisfied: chatContentModule.viewAndPostPermissionsSatisfied
property bool hasViewOnlyPermissions: false
property bool hasUnrestrictedViewOnlyPermission: false
property bool hasViewAndPostPermissions: false
property bool amIMember: false
property bool amISectionAdmin: false
@ -92,6 +95,9 @@ StatusSectionLayout {
return false
}
if (!amIMember) {
if (hasUnrestrictedViewOnlyPermission)
return false
return hasViewAndPostPermissions || hasViewOnlyPermissions
}
if (amISectionAdmin) {