feat(communities): add check permissions pending state

closes: #11157
This commit is contained in:
Patryk Osmaczko 2023-08-04 15:14:06 +02:00 committed by osmaczko
parent 34dba08b7a
commit 15701e91aa
16 changed files with 111 additions and 3 deletions

View File

@ -133,3 +133,6 @@ method onUpdateViewOnlyPermissionsSatisfied*(self: AccessInterface, value: bool)
method onUpdateViewAndPostPermissionsSatisfied*(self: AccessInterface, value: bool) {.base.} =
raise newException(ValueError, "No implementation available")
method setPermissionsCheckOngoing*(self: AccessInterface, value: bool) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -407,3 +407,6 @@ method onUpdateViewOnlyPermissionsSatisfied*(self: Module, value: bool) =
method onUpdateViewAndPostPermissionsSatisfied*(self: Module, value: bool) =
self.view.setViewAndPostPermissionsSatisfied(value)
method setPermissionsCheckOngoing*(self: Module, value: bool) =
self.view.setPermissionsCheckOngoing(value)

View File

@ -15,6 +15,7 @@ QtObject:
chatDetailsVariant: QVariant
viewOnlyPermissionsSatisfied: bool
viewAndPostPermissionsSatisfied: bool
permissionsCheckOngoing: bool
proc chatDetailsChanged*(self:View) {.signal.}
@ -179,3 +180,17 @@ QtObject:
read = getViewAndPostPermissionsSatisfied
notify = viewAndPostPermissionsSatisfiedChanged
proc getPermissionsCheckOngoing*(self: View): bool {.slot.} =
return self.permissionsCheckOngoing
proc permissionsCheckOngoingChanged*(self: View) {.signal.}
QtProperty[bool] permissionsCheckOngoing:
read = getPermissionsCheckOngoing
notify = permissionsCheckOngoingChanged
proc setPermissionsCheckOngoing*(self: View, value: bool) =
if (value == self.permissionsCheckOngoing):
return
self.permissionsCheckOngoing = value
self.permissionsCheckOngoingChanged()

View File

@ -85,9 +85,11 @@ proc getMySectionId*(self: Controller): string =
proc asyncCheckPermissionsToJoin*(self: Controller) =
self.communityService.asyncCheckPermissionsToJoin(self.getMySectionId())
self.delegate.setPermissionsToJoinCheckOngoing(true)
proc asyncCheckAllChannelsPermissions*(self: Controller) =
self.chatService.asyncCheckAllChannelsPermissions(self.getMySectionId())
self.delegate.setChannelsPermissionsCheckOngoing(true)
proc asyncCheckChannelPermissions*(self: Controller, communityId: string, chatId: string) =
self.chatService.asyncCheckChannelPermissions(communityId, chatId)

View File

@ -393,3 +393,9 @@ method onCommunityCheckChannelPermissionsResponse*(self: AccessInterface, chatId
method onCommunityCheckAllChannelsPermissionsResponse*(self: AccessInterface, checkAllChannelsPermissionsResponse: CheckAllChannelsPermissionsResponseDto) {.base.} =
raise newException(ValueError, "No implementation available")
method setPermissionsToJoinCheckOngoing*(self: AccessInterface, value: bool) {.base.} =
raise newException(ValueError, "No implementation available")
method setChannelsPermissionsCheckOngoing*(self: AccessInterface, value: bool) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -298,6 +298,13 @@ QtObject:
let modelIndex = self.createIndex(index, 0, nil)
self.dataChanged(modelIndex, modelIndex, @[ModelRole.RequiresPermissions.int])
proc getItemPermissionsRequired*(self: Model, id: string): bool =
let index = self.getItemIdxById(id)
if index == -1:
return false
return self.items[index].requiresPermissions
proc changeMutedOnItemById*(self: Model, id: string, muted: bool) =
let index = self.getItemIdxById(id)
if index == -1:

View File

@ -843,11 +843,13 @@ proc updateChannelPermissionViewData*(self: Module, chatId: string, viewOnlyPerm
if self.chatContentModules.hasKey(chatId):
self.chatContentModules[chatId].onUpdateViewOnlyPermissionsSatisfied(viewOnlyPermissions.satisfied)
self.chatContentModules[chatId].onUpdateViewAndPostPermissionsSatisfied(viewAndPostPermissions.satisfied)
self.chatContentModules[chatId].setPermissionsCheckOngoing(false)
method onCommunityCheckPermissionsToJoinResponse*(self: Module, checkPermissionsToJoinResponse: CheckPermissionsToJoinResponseDto) =
let community = self.controller.getMyCommunity()
self.view.setAllTokenRequirementsMet(checkPermissionsToJoinResponse.satisfied)
self.updateTokenPermissionModel(checkPermissionsToJoinResponse.permissions, community)
self.setPermissionsToJoinCheckOngoing(false)
method onCommunityTokenPermissionUpdated*(self: Module, communityId: string, tokenPermission: CommunityTokenPermissionDto) =
let chats = self.controller.getChatDetailsByIds(tokenPermission.chatIDs)
@ -1317,3 +1319,11 @@ method setCommunityMetrics*(self: Module, metrics: CommunityMetricsDto) =
method collectCommunityMetricsMessagesCount*(self: Module, intervals: string) =
self.controller.collectCommunityMetricsMessagesCount(intervals)
method setPermissionsToJoinCheckOngoing*(self: Module, value: bool) =
self.view.setPermissionsCheckOngoing(value)
method setChannelsPermissionsCheckOngoing*(self: Module, value: bool) =
for chatId, cModule in self.chatContentModules:
if self.view.chatsModel().getItemPermissionsRequired(chatId):
cModule.setPermissionsCheckOngoing(true)

View File

@ -28,7 +28,7 @@ QtObject:
amIMember: bool
chatsLoaded: bool
communityMetrics: string # NOTE: later this should be replaced with QAbstractListModel-based model
permissionsCheckOngoing: bool
proc delete*(self: View) =
self.model.delete
@ -430,4 +430,19 @@ QtObject:
self.delegate.collectCommunityMetricsMessagesTimestamps(intervals)
proc collectCommunityMetricsMessagesCount*(self: View, intervals: string) {.slot.} =
self.delegate.collectCommunityMetricsMessagesCount(intervals)
self.delegate.collectCommunityMetricsMessagesCount(intervals)
proc getPermissionsCheckOngoing*(self: View): bool {.slot.} =
return self.permissionsCheckOngoing
proc permissionsCheckOngoingChanged*(self: View) {.signal.}
QtProperty[bool] permissionsCheckOngoing:
read = getPermissionsCheckOngoing
notify = permissionsCheckOngoingChanged
proc setPermissionsCheckOngoing*(self: View, value: bool) =
if (value == self.permissionsCheckOngoing):
return
self.permissionsCheckOngoing = value
self.permissionsCheckOngoingChanged()

View File

@ -13,6 +13,7 @@ ColumnLayout {
property string channelName: "#vip"
property bool joinCommunity: true // Otherwise, enter channel
property bool requirementsMet: true
property bool requirementsCheckPending: false
property bool isInvitationPending: false
property bool isJoinRequestRejected: false
property bool requiresRequest: false
@ -55,6 +56,19 @@ ColumnLayout {
}
}
ColumnLayout {
visible: !isOnlyChannelPanelEditor
Label {
Layout.fillWidth: true
text: "Requirements check pending:"
}
CheckBox {
checked: root.requirementsCheckPending
onCheckedChanged: root.requirementsCheckPending = checked
}
}
ColumnLayout {
visible: !isOnlyChannelPanelEditor
Label {

View File

@ -21,6 +21,7 @@ SplitView {
property string channelName: "vip"
property bool joinCommunity: true // Otherwise, enter channel
property bool requirementsMet: true
property bool requirementsCheckPending: false
property bool isInvitationPending: false
property bool isJoinRequestRejected: false
property bool requiresRequest: false
@ -74,6 +75,7 @@ SplitView {
anchors.centerIn: parent
joinCommunity: d.joinCommunity
requirementsMet: d.requirementsMet
requirementsCheckPending: d.requirementsCheckPending
isInvitationPending: d.isInvitationPending
isJoinRequestRejected: d.isJoinRequestRejected
requiresRequest: d.requiresRequest
@ -151,6 +153,7 @@ SplitView {
channelName: d.chanelName
joinCommunity: d.joinCommunity
requirementsMet: d.requirementsMet
requirementsCheckPending: d.requirementsCheckPending
isInvitationPending: d.isInvitationPending
isJoinRequestRejected: d.isJoinRequestRejected
requiresRequest: d.requiresRequest
@ -158,6 +161,7 @@ SplitView {
onChannelNameChanged: d.channelName = channelName
onJoinCommunityChanged: d.joinCommunity = joinCommunity
onRequirementsMetChanged: d.requirementsMet = requirementsMet
onRequirementsCheckPendingChanged: d.requirementsCheckPending = requirementsCheckPending
onIsInvitationPendingChanged: d.isInvitationPending = isInvitationPending
onIsJoinRequestRejectedChanged: d.isJoinRequestRejected = isJoinRequestRejected
onRequiresRequestChanged: d.requiresRequest = requiresRequest

View File

@ -58,6 +58,7 @@ StackLayout {
communityData.memberRole === Constants.memberRole.admin
communityItemsModel: root.rootStore.communityItemsModel
requirementsMet: root.permissionsStore.allTokenRequirementsMet
requirementsCheckPending: root.rootStore.permissionsCheckOngoing
requiresRequest: !communityData.amIMember
communityHoldingsModel: root.permissionsStore.becomeMemberPermissionsModel
viewOnlyHoldingsModel: root.permissionsStore.viewOnlyPermissionsModel

View File

@ -77,6 +77,8 @@ QtObject {
property var advancedModule: profileSectionModule.advancedModule
readonly property bool permissionsCheckOngoing: chatCommunitySectionModule.permissionsCheckOngoing
signal importingCommunityStateChanged(string communityId, int state, string errorMsg)
signal communityAdded(string communityId)

View File

@ -204,6 +204,7 @@ StatusSectionLayout {
requiresRequest: !root.amIMember
requirementsMet: (viewOnlyPermissionsSatisfied && viewOnlyPermissionsModel.count > 0) ||
(viewAndPostPermissionsSatisfied && viewAndPostPermissionsModel.count > 0)
requirementsCheckPending: root.chatContentModule.permissionsCheckOngoing
onRevealAddressClicked: root.revealAddressClicked()
onInvitationPendingClicked: root.invitationPendingClicked()
}

View File

@ -22,6 +22,7 @@ ColumnLayout {
property alias loginType: overlayPanel.loginType
property bool requirementsMet: true
property bool requirementsCheckPending: false
property var communityHoldingsModel
property var viewOnlyHoldingsModel
@ -140,6 +141,7 @@ ColumnLayout {
topPadding: 2 * bottomPadding
joinCommunity: root.joinCommunity
requirementsMet: root.requirementsMet
requirementsCheckPending: root.requirementsCheckPending
isInvitationPending: root.isInvitationPending
isJoinRequestRejected: root.isJoinRequestRejected
requiresRequest: root.requiresRequest

View File

@ -19,6 +19,7 @@ Control {
property bool joinCommunity: true // Otherwise it means join channel action
property bool requirementsMet: false
property bool requirementsCheckPending: false
property bool requiresRequest: false
property bool isInvitationPending: false
property bool isJoinRequestRejected: false
@ -162,10 +163,30 @@ Control {
StatusBaseText {
Layout.alignment: Qt.AlignHCenter
visible: !root.showOnlyPanels && (root.isJoinRequestRejected || !root.requirementsMet)
visible: !root.showOnlyPanels && !root.requirementsCheckPending && (root.isJoinRequestRejected || !root.requirementsMet)
text: root.isJoinRequestRejected ? d.memberchipRequestRejectedText :
(root.joinCommunity ? d.communityRequirementsNotMetText : d.channelRequirementsNotMetText)
color: Theme.palette.dangerColor1
}
StatusBaseText {
id: requirementsCheckPendingText
Layout.alignment: Qt.AlignHCenter
visible: root.requirementsCheckPending
text: qsTr("Requirements check pending...")
color: Theme.palette.dangerColor1
SequentialAnimation {
id: blinkingAnimation
loops: Animation.Infinite
running: requirementsCheckPendingText.visible
NumberAnimation { target: requirementsCheckPendingText; property: "opacity"; to: 0; duration: 1500;}
NumberAnimation { target: requirementsCheckPendingText; property: "opacity"; to: 1; duration: 1500;}
}
}
}
}

View File

@ -34,6 +34,7 @@ StatusSectionLayout {
// Permission overlay view properties:
property bool requirementsMet: true
property bool requirementsCheckPending: false
property bool isJoinRequestRejected: false
property bool requiresRequest: false
property alias loginType: joinCommunityCenterPanel.loginType
@ -132,6 +133,7 @@ StatusSectionLayout {
isJoinRequestRejected: root.isJoinRequestRejected
requiresRequest: root.requiresRequest
requirementsMet: root.requirementsMet
requirementsCheckPending: root.requirementsCheckPending
communityHoldingsModel: root.communityHoldingsModel
viewOnlyHoldingsModel: root.viewOnlyHoldingsModel