From 953fff0e68b548295c97e3a1df51001b2b8e8faa Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Tue, 7 May 2024 14:46:54 -0400 Subject: [PATCH] feat(community): show a message when the member reevaluation is ongoing Fixes #14378 --- .../core/signals/remote_signals/community.nim | 23 +++++++++++++++ .../signals/remote_signals/signal_type.nim | 1 + src/app/core/signals/signals_manager.nim | 1 + .../modules/main/chat_section/controller.nim | 5 ++++ .../main/chat_section/io_interface.nim | 4 +++ src/app/modules/main/chat_section/module.nim | 4 +++ src/app/modules/main/chat_section/view.nim | 19 +++++++++++- src/app_service/service/community/service.nim | 13 +++++++++ .../AppLayouts/Chat/panels/UserListPanel.qml | 29 ++++++++++++++++++- ui/app/AppLayouts/Chat/stores/RootStore.qml | 2 ++ ui/app/AppLayouts/Chat/views/ChatView.qml | 1 + ui/imports/utils/Constants.qml | 6 ++++ vendor/status-go | 2 +- 13 files changed, 107 insertions(+), 3 deletions(-) diff --git a/src/app/core/signals/remote_signals/community.nim b/src/app/core/signals/remote_signals/community.nim index 5397e408c9..6781619adb 100644 --- a/src/app/core/signals/remote_signals/community.nim +++ b/src/app/core/signals/remote_signals/community.nim @@ -5,6 +5,8 @@ import ../../../../app_service/service/community/dto/[community] import ../../../../app_service/service/chat/dto/[chat] import signal_type +include app_service/common/json_utils + type CommunitySignal* = ref object of Signal community*: CommunityDto @@ -59,6 +61,16 @@ type DiscordCommunityImportFinishedSignal* = ref object of Signal type DiscordChannelImportCancelledSignal* = ref object of Signal channelId*: string +type + CommunityMemberReevaluationStatus* {.pure.} = enum + None = 0, + InProgress, + Done, + +type CommunityMemberReevaluationStatusSignal* = ref object of Signal + communityId*: string + status*: CommunityMemberReevaluationStatus + type DiscordChannelImportFinishedSignal* = ref object of Signal communityId*: string channelId*: string @@ -174,6 +186,17 @@ proc fromEvent*(T: type DiscordChannelImportCancelledSignal, event: JsonNode): D result.signalType = SignalType.DiscordChannelImportCancelled result.channelId = event["event"]{"channelId"}.getStr() +proc fromEvent*(T: type CommunityMemberReevaluationStatusSignal, event: JsonNode): CommunityMemberReevaluationStatusSignal = + result = CommunityMemberReevaluationStatusSignal() + result.signalType = SignalType.MemberReevaluationStatus + result.communityId = event["event"]{"communityId"}.getStr() + + result.status = CommunityMemberReevaluationStatus.None + var statusInt: int + if (event["event"].getProp("status", statusInt) and (statusInt >= ord(low(CommunityMemberReevaluationStatus)) and + statusInt <= ord(high(CommunityMemberReevaluationStatus)))): + result.status = CommunityMemberReevaluationStatus(statusInt) + proc createFromEvent*(T: type HistoryArchivesSignal, event: JsonNode): HistoryArchivesSignal = result = HistoryArchivesSignal() result.communityId = event["event"]{"communityId"}.getStr() diff --git a/src/app/core/signals/remote_signals/signal_type.nim b/src/app/core/signals/remote_signals/signal_type.nim index 4e4e4157fb..203f6bed9a 100644 --- a/src/app/core/signals/remote_signals/signal_type.nim +++ b/src/app/core/signals/remote_signals/signal_type.nim @@ -52,6 +52,7 @@ type SignalType* {.pure.} = enum DiscordChannelImportFinished = "community.discordChannelImportFinished" DiscordChannelImportProgress = "community.discordChannelImportProgress" DiscordChannelImportCancelled = "community.discordChannelImportCancelled" + MemberReevaluationStatus = "community.memberReevaluationStatus" WakuFetchingBackupProgress = "waku.fetching.backup.progress" WakuBackedUpProfile = "waku.backedup.profile" WakuBackedUpSettings = "waku.backedup.settings" diff --git a/src/app/core/signals/signals_manager.nim b/src/app/core/signals/signals_manager.nim index 0afe1d0dc4..6e8cf15719 100644 --- a/src/app/core/signals/signals_manager.nim +++ b/src/app/core/signals/signals_manager.nim @@ -121,6 +121,7 @@ QtObject: of SignalType.DiscordChannelImportFinished: DiscordChannelImportFinishedSignal.fromEvent(jsonSignal) of SignalType.DiscordChannelImportProgress: DiscordChannelImportProgressSignal.fromEvent(jsonSignal) of SignalType.DiscordChannelImportCancelled: DiscordChannelImportCancelledSignal.fromEvent(jsonSignal) + of SignalType.MemberReevaluationStatus: CommunityMemberReevaluationStatusSignal.fromEvent(jsonSignal) # sync from waku part of SignalType.WakuFetchingBackupProgress: WakuFetchingBackupProgressSignal.fromEvent(jsonSignal) of SignalType.WakuBackedUpProfile: WakuBackedUpProfileSignal.fromEvent(jsonSignal) diff --git a/src/app/modules/main/chat_section/controller.nim b/src/app/modules/main/chat_section/controller.nim index 827e9487c2..442d4288d2 100644 --- a/src/app/modules/main/chat_section/controller.nim +++ b/src/app/modules/main/chat_section/controller.nim @@ -367,6 +367,11 @@ proc init*(self: Controller) = if args.communityId == self.sectionId: self.delegate.setShardingInProgress(false) + self.events.on(SIGNAL_MEMBER_REEVALUATION_STATUS) do(e: Args): + let args = CommunityMemberReevaluationStatusArg(e) + if args.communityId == self.sectionId: + self.delegate.communityMemberReevaluationStatusUpdated(args.status) + self.events.on(SIGNAL_CONTACT_NICKNAME_CHANGED) do(e: Args): var args = ContactArgs(e) self.delegate.onContactDetailsUpdated(args.contactId) diff --git a/src/app/modules/main/chat_section/io_interface.nim b/src/app/modules/main/chat_section/io_interface.nim index 9bd66681b7..e220fc6d45 100644 --- a/src/app/modules/main/chat_section/io_interface.nim +++ b/src/app/modules/main/chat_section/io_interface.nim @@ -9,6 +9,7 @@ import ../../../../app_service/service/message/service as message_service import ../../../../app_service/service/mailservers/service as mailservers_service import ../../../../app_service/service/shared_urls/service as shared_urls_service import ../../../../app_service/common/types +import ../../../../app/core/signals/types import model as chats_model import item as chat_item @@ -428,3 +429,6 @@ method openCommunityChatAndScrollToMessage*(self: AccessInterface, chatId: strin method updateRequestToJoinState*(self: AccessInterface, state: RequestToJoinState) {.base.} = raise newException(ValueError, "No implementation available") + +method communityMemberReevaluationStatusUpdated*(self: AccessInterface, status: CommunityMemberReevaluationStatus) {.base.} = + raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index 50fd1fc545..fe8d7c6f4c 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -37,6 +37,7 @@ import ../../../../app_service/service/community_tokens/service as community_tok import ../../../../app_service/service/shared_urls/service as shared_urls_service import ../../../../app_service/service/visual_identity/service as visual_identity import ../../../../app_service/service/contacts/dto/contacts as contacts_dto +import ../../../../app/core/signals/types export io_interface @@ -1588,3 +1589,6 @@ method openCommunityChatAndScrollToMessage*(self: Module, chatId: string, messag method updateRequestToJoinState*(self: Module, state: RequestToJoinState) = self.view.setRequestToJoinState(state) + +method communityMemberReevaluationStatusUpdated*(self: Module, status: CommunityMemberReevaluationStatus) = + self.view.setCommunityMemberReevaluationStatus(status.int) diff --git a/src/app/modules/main/chat_section/view.nim b/src/app/modules/main/chat_section/view.nim index d7cbf0d5bf..4cf7303303 100644 --- a/src/app/modules/main/chat_section/view.nim +++ b/src/app/modules/main/chat_section/view.nim @@ -37,6 +37,7 @@ QtObject: memberMessagesModel: member_msg_model.Model memberMessagesModelVariant: QVariant requestToJoinState: RequestToJoinState + communityMemberReevaluationStatus: int proc delete*(self: View) = @@ -82,6 +83,7 @@ QtObject: result.memberMessagesModel = member_msg_model.newModel() result.memberMessagesModelVariant = newQVariant(result.memberMessagesModel) result.requestToJoinState = RequestToJoinState.None + result.communityMemberReevaluationStatus = 0 proc load*(self: View) = self.delegate.viewDidLoad() @@ -554,4 +556,19 @@ QtObject: if self.requestToJoinState == requestToJoinState: return self.requestToJoinState = requestToJoinState - self.requestToJoinStateChanged() \ No newline at end of file + self.requestToJoinStateChanged() + + proc communityMemberReevaluationStatusChanged*(self: View) {.signal.} + + proc getCommunityMemberReevaluationStatus*(self: View): int {.slot.} = + return self.communityMemberReevaluationStatus + + QtProperty[int] communityMemberReevaluationStatus: + read = getCommunityMemberReevaluationStatus + notify = communityMemberReevaluationStatusChanged + + proc setCommunityMemberReevaluationStatus*(self: View, value: int) = + if self.communityMemberReevaluationStatus == value: + return + self.communityMemberReevaluationStatus = value + self.communityMemberReevaluationStatusChanged() \ No newline at end of file diff --git a/src/app_service/service/community/service.nim b/src/app_service/service/community/service.nim index c0edc0d2f7..6205d58831 100644 --- a/src/app_service/service/community/service.nim +++ b/src/app_service/service/community/service.nim @@ -167,6 +167,10 @@ type CommunityShardSetArgs* = ref object of Args communityId*: string + CommunityMemberReevaluationStatusArg* = ref object of Args + communityId*: string + status*: CommunityMemberReevaluationStatus + # Signals which may be emitted by this service: const SIGNAL_COMMUNITY_DATA_LOADED* = "communityDataLoaded" const SIGNAL_COMMUNITY_JOINED* = "communityJoined" @@ -220,6 +224,8 @@ const SIGNAL_DISCORD_CHANNEL_IMPORT_FINISHED* = "discordChannelImportFinished" const SIGNAL_DISCORD_CHANNEL_IMPORT_PROGRESS* = "discordChannelImportProgress" const SIGNAL_DISCORD_CHANNEL_IMPORT_CANCELED* = "discordChannelImportCanceled" +const SIGNAL_MEMBER_REEVALUATION_STATUS* = "communityMemberReevaluationStatus" + const SIGNAL_COMMUNITY_TOKEN_PERMISSION_CREATED* = "communityTokenPermissionCreated" const SIGNAL_COMMUNITY_TOKEN_PERMISSION_CREATION_FAILED* = "communityTokenPermissionCreationFailed" const SIGNAL_COMMUNITY_TOKEN_PERMISSION_UPDATED* = "communityTokenPermissionUpdated" @@ -422,6 +428,13 @@ QtObject: # Don't just emit this signal when all communities are done downloading history data, # but implement a solution for individual updates self.events.emit(SIGNAL_COMMUNITY_HISTORY_ARCHIVES_DOWNLOAD_FINISHED, CommunityIdArgs(communityId: receivedData.communityId)) + + self.events.on(SignalType.MemberReevaluationStatus.event) do(e: Args): + var receivedData = CommunityMemberReevaluationStatusSignal(e) + self.events.emit(SIGNAL_MEMBER_REEVALUATION_STATUS, CommunityMemberReevaluationStatusArg( + communityId: receivedData.communityId, + status: receivedData.status, + )) proc findIndexById(id: string, chats: seq[ChatDto]): int = var idx = -1 diff --git a/ui/app/AppLayouts/Chat/panels/UserListPanel.qml b/ui/app/AppLayouts/Chat/panels/UserListPanel.qml index e8bec61e2f..ac699d4ff2 100644 --- a/ui/app/AppLayouts/Chat/panels/UserListPanel.qml +++ b/ui/app/AppLayouts/Chat/panels/UserListPanel.qml @@ -5,6 +5,7 @@ import StatusQ 0.1 import StatusQ.Core 0.1 import StatusQ.Core.Theme 0.1 import StatusQ.Components 0.1 +import StatusQ.Controls 0.1 import shared 1.0 import shared.panels 1.0 @@ -20,6 +21,7 @@ Item { property var store property var usersModel property string label + property int communityMemberReevaluationStatus: Constants.CommunityMemberReevaluationStatus.None StatusBaseText { id: titleText @@ -35,9 +37,34 @@ Item { text: root.label } + StatusBaseText { + id: communityMemberReevaluationInProgressText + visible: root.communityMemberReevaluationStatus === Constants.CommunityMemberReevaluationStatus.InProgress + height: visible ? implicitHeight : 0 + anchors.top: titleText.bottom + anchors.topMargin: visible ? Style.current.padding : 0 + anchors.left: parent.left + anchors.leftMargin: Style.current.padding + anchors.right: parent.right + anchors.rightMargin: Style.current.padding + font.pixelSize: Style.current.secondaryTextFontSize + color: Theme.palette.directColor1 + text: qsTr("Member re-evaluation in progress...") + wrapMode: Text.WordWrap + + StatusToolTip { + text: qsTr("Saving community edits might take longer than usual") + visible: hoverHandler.hovered + } + HoverHandler { + id: hoverHandler + enabled: communityMemberReevaluationInProgressText.visible + } + } + Item { anchors { - top: titleText.bottom + top: communityMemberReevaluationInProgressText.bottom topMargin: Style.current.padding left: parent.left leftMargin: Style.current.halfPadding diff --git a/ui/app/AppLayouts/Chat/stores/RootStore.qml b/ui/app/AppLayouts/Chat/stores/RootStore.qml index 4caa7fe830..6c8d95c0ac 100644 --- a/ui/app/AppLayouts/Chat/stores/RootStore.qml +++ b/ui/app/AppLayouts/Chat/stores/RootStore.qml @@ -64,6 +64,8 @@ QtObject { readonly property bool allChannelsAreHiddenBecauseNotPermitted: root.chatCommunitySectionModule.allChannelsAreHiddenBecauseNotPermitted && !root.chatCommunitySectionModule.requiresTokenPermissionToJoin + readonly property int communityMemberReevaluationStatus: root.chatCommunitySectionModule && root.chatCommunitySectionModule.communityMemberReevaluationStatus + readonly property bool requirementsCheckPending: root.communitiesModuleInst.requirementsCheckPending readonly property var permissionsModel: !!root.communitiesModuleInst.spectatedCommunityPermissionModel ? diff --git a/ui/app/AppLayouts/Chat/views/ChatView.qml b/ui/app/AppLayouts/Chat/views/ChatView.qml index c0a661c18f..75b4eaa414 100644 --- a/ui/app/AppLayouts/Chat/views/ChatView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatView.qml @@ -186,6 +186,7 @@ StatusSectionLayout { anchors.fill: parent store: root.rootStore label: qsTr("Members") + communityMemberReevaluationStatus: root.rootStore.communityMemberReevaluationStatus usersModel: root.chatContentModule && root.chatContentModule.usersModule ? root.chatContentModule.usersModule.model : null } } diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index 32baf602da..c1549183c1 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -1312,4 +1312,10 @@ QtObject { InProgress = 1, Requested = 2 } + + enum CommunityMemberReevaluationStatus { + None = 0, + InProgress = 1, + Done = 2 + } } diff --git a/vendor/status-go b/vendor/status-go index 7ba9a00fee..5f4aab3121 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit 7ba9a00fee18d0216cf3c2c24909d067cd1d2e3d +Subproject commit 5f4aab3121a6ef2c0c6d25111500fd58c762b8fb