From b75d8630cab84712bbbcc9616fc49fd18362a26f Mon Sep 17 00:00:00 2001 From: Mikhail Rogachev Date: Sat, 22 Jul 2023 01:05:42 +0400 Subject: [PATCH] feat: use community.isControlNode as visible for archiveSupporVisible (#11560) Close #11089 --- src/app/modules/main/communities/module.nim | 1 + src/app/modules/main/module.nim | 1 + src/app/modules/shared_models/section_item.nim | 7 +++++++ src/app/modules/shared_models/section_model.nim | 6 ++++++ src/app_service/service/community/dto/community.nim | 2 ++ storybook/pages/CommunitiesViewPage.qml | 6 ++++++ storybook/pages/ProfileDialogViewPage.qml | 3 +++ storybook/pages/ProfileShowcaseCommunitiesPanelPage.qml | 5 +++++ ui/app/AppLayouts/Communities/controls/Options.qml | 4 +++- .../Communities/panels/OverviewSettingsPanel.qml | 2 ++ .../AppLayouts/Communities/popups/CreateCommunityPopup.qml | 1 + .../AppLayouts/Communities/views/CommunitySettingsView.qml | 1 + vendor/status-go | 2 +- 13 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/app/modules/main/communities/module.nim b/src/app/modules/main/communities/module.nim index 2ad90751c8..c45565c05b 100644 --- a/src/app/modules/main/communities/module.nim +++ b/src/app/modules/main/communities/module.nim @@ -145,6 +145,7 @@ method getCommunityItem(self: Module, c: CommunityDto): SectionItem = SectionType.Community, c.name, c.memberRole, + c.isControlNode, c.description, c.introMessage, c.outroMessage, diff --git a/src/app/modules/main/module.nim b/src/app/modules/main/module.nim index 440ef933a2..1179a5e8bb 100644 --- a/src/app/modules/main/module.nim +++ b/src/app/modules/main/module.nim @@ -265,6 +265,7 @@ proc createChannelGroupItem[T](self: Module[T], channelGroup: ChannelGroupDto): if isCommunity: SectionType.Community else: SectionType.Chat, if isCommunity: channelGroup.name else: conf.CHAT_SECTION_NAME, channelGroup.memberRole, + if isCommunity: communityDetails.isControlNode else: false, channelGroup.description, channelGroup.introMessage, channelGroup.outroMessage, diff --git a/src/app/modules/shared_models/section_item.nim b/src/app/modules/shared_models/section_item.nim index e6b646e155..e0269343ea 100644 --- a/src/app/modules/shared_models/section_item.nim +++ b/src/app/modules/shared_models/section_item.nim @@ -26,6 +26,7 @@ type id: string name: string memberRole: MemberRole + isControlNode: bool description: string introMessage: string outroMessage: string @@ -62,6 +63,7 @@ proc initItem*( sectionType: SectionType, name: string, memberRole = MemberRole.None, + isControlNode = false, description = "", introMessage = "", outroMessage = "", @@ -97,6 +99,7 @@ proc initItem*( result.sectionType = sectionType result.name = name result.memberRole = memberRole + result.isControlNode = isControlNode result.description = description result.introMessage = introMessage result.outroMessage = outroMessage @@ -143,6 +146,7 @@ proc `$`*(self: SectionItem): string = sectionType: {self.sectionType.int}, name: {self.name}, memberRole: {self.memberRole}, + isControlNode: {self.isControlNode}, description: {self.description}, introMessage: {self.introMessage}, outroMessage: {self.outroMessage}, @@ -189,6 +193,9 @@ proc memberRole*(self: SectionItem): MemberRole {.inline.} = proc `memberRole=`*(self: var SectionItem, value: MemberRole) {.inline.} = self.memberRole = value +proc isControlNode*(self: SectionItem): bool {.inline.} = + self.isControlNode + proc description*(self: SectionItem): string {.inline.} = self.description diff --git a/src/app/modules/shared_models/section_model.nim b/src/app/modules/shared_models/section_model.nim index 82731e5af1..c5efaff90d 100644 --- a/src/app/modules/shared_models/section_model.nim +++ b/src/app/modules/shared_models/section_model.nim @@ -13,6 +13,7 @@ type SectionType Name MemberRole + IsControlNode Description IntroMessage OutroMessage @@ -85,6 +86,7 @@ QtObject: ModelRole.SectionType.int:"sectionType", ModelRole.Name.int:"name", ModelRole.MemberRole.int: "memberRole", + ModelRole.IsControlNode.int: "isControlNode", ModelRole.Description.int:"description", ModelRole.IntroMessage.int:"introMessage", ModelRole.OutroMessage.int:"outroMessage", @@ -137,6 +139,8 @@ QtObject: result = newQVariant(item.name) of ModelRole.MemberRole: result = newQVariant(item.memberRole.int) + of ModelRole.IsControlNode: + result = newQVariant(item.isControlNode) of ModelRole.Description: result = newQVariant(item.description) of ModelRole.IntroMessage: @@ -273,6 +277,7 @@ QtObject: self.dataChanged(dataIndex, dataIndex, @[ ModelRole.Name.int, ModelRole.MemberRole.int, + ModelRole.IsControlNode.int, ModelRole.Description.int, ModelRole.IntroMessage.int, ModelRole.OutroMessage.int, @@ -415,6 +420,7 @@ QtObject: "id": item.id, "name": item.name, "memberRole": item.memberRole.int, + "isControlNode": item.isControlNode, "description": item.description, "introMessage": item.introMessage, "outroMessage": item.outroMessage, diff --git a/src/app_service/service/community/dto/community.nim b/src/app_service/service/community/dto/community.nim index e5112cbc5c..b4b49d6bd8 100644 --- a/src/app_service/service/community/dto/community.nim +++ b/src/app_service/service/community/dto/community.nim @@ -91,6 +91,7 @@ type CheckPermissionsToJoinResponseDto* = object type CommunityDto* = object id*: string memberRole*: MemberRole + isControlNode*: bool verified*: bool joined*: bool spectated*: bool @@ -304,6 +305,7 @@ proc toCommunityDto*(jsonObj: JsonNode): CommunityDto = result = CommunityDto() discard jsonObj.getProp("id", result.id) discard jsonObj.getProp("memberRole", result.memberRole) + discard jsonObj.getProp("isControlNode", result.isControlNode) discard jsonObj.getProp("verified", result.verified) discard jsonObj.getProp("joined", result.joined) discard jsonObj.getProp("spectated", result.spectated) diff --git a/storybook/pages/CommunitiesViewPage.qml b/storybook/pages/CommunitiesViewPage.qml index f79add603b..74a5d31f01 100644 --- a/storybook/pages/CommunitiesViewPage.qml +++ b/storybook/pages/CommunitiesViewPage.qml @@ -38,6 +38,7 @@ SplitView { joined: true, spectated: false, memberRole: Constants.memberRole.owner, + isControlNode: true, image: ModelsData.icons.dribble, color: "yellow", muted: false, @@ -52,6 +53,7 @@ SplitView { joined: true, spectated: false, memberRole: Constants.memberRole.none, + isControlNode: false, image: ModelsData.icons.status, color: "peach", muted: false, @@ -66,6 +68,7 @@ SplitView { joined: false, spectated: true, memberRole: Constants.memberRole.none, + isControlNode: false, image: ModelsData.icons.coinbase, color: "red", muted: false, @@ -80,6 +83,7 @@ SplitView { joined: true, spectated: false, memberRole: Constants.memberRole.none, + isControlNode: false, image: "", color: "whitesmoke", muted: true, @@ -94,6 +98,7 @@ SplitView { joined: true, spectated: false, memberRole: Constants.memberRole.admin, + isControlNode: false, image: ModelsData.icons.socks, color: "green", muted: false, @@ -108,6 +113,7 @@ SplitView { joined: false, spectated: true, memberRole: Constants.memberRole.none, + isControlNode: false, image: ModelsData.icons.spotify, color: "pink", muted: false, diff --git a/storybook/pages/ProfileDialogViewPage.qml b/storybook/pages/ProfileDialogViewPage.qml index ce921649df..4f3a5b7990 100644 --- a/storybook/pages/ProfileDialogViewPage.qml +++ b/storybook/pages/ProfileDialogViewPage.qml @@ -175,6 +175,7 @@ SplitView { ListElement { name: "Not the cool gang" memberRole: 0 // Constants.memberRole.none + isControlNode: false, description: "Nothing to write home about" color: "indigo" image: "" @@ -186,6 +187,7 @@ SplitView { ListElement { name: "Awesome bunch" memberRole: 4 // Constants.memberRole.admin + isControlNode: false, description: "Where the cool guys hang out & Nothing to write home about" color: "green" image: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAlklEQVR4nOzW0QmDQBAG4SSkl7SUQlJGCrElq9F3QdjjVhh/5nv3cFhY9vUIYQiNITSG0BhCExPynn1gWf9bx498P7/ @@ -202,6 +204,7 @@ SplitView { ListElement { name: "Invisible community (should not display!)" memberRole: 1 // Constants.memberRole.owner + isControlNode: true, description: "Get outta here" color: "red" image: "" diff --git a/storybook/pages/ProfileShowcaseCommunitiesPanelPage.qml b/storybook/pages/ProfileShowcaseCommunitiesPanelPage.qml index d50ccf849f..c5ad145ffa 100644 --- a/storybook/pages/ProfileShowcaseCommunitiesPanelPage.qml +++ b/storybook/pages/ProfileShowcaseCommunitiesPanelPage.qml @@ -32,6 +32,7 @@ SplitView { name: "Test community", joined: true, memberRole: Constants.memberRole.owner, + isControlNode: true, image: ModelsData.icons.dribble, color: "yellow" }, @@ -40,6 +41,7 @@ SplitView { name: "Test community 2", joined: true, memberRole: Constants.memberRole.none, + isControlNode: false, image: ModelsData.collectibles.custom, color: "peach" }, @@ -48,6 +50,7 @@ SplitView { name: "Test community invisible", joined: false, memberRole: Constants.memberRole.none, + isControlNode: false, image: "", color: "red" }, @@ -56,6 +59,7 @@ SplitView { name: "Test community 3", joined: true, memberRole: Constants.memberRole.none, + isControlNode: false, image: "", color: "whitesmoke" }, @@ -64,6 +68,7 @@ SplitView { name: "Test community 4", joined: true, memberRole: Constants.memberRole.admin, + isControlNode: false, image: ModelsData.icons.spotify, color: "green" }, diff --git a/ui/app/AppLayouts/Communities/controls/Options.qml b/ui/app/AppLayouts/Communities/controls/Options.qml index 9b8a99ab3c..54348f0c56 100644 --- a/ui/app/AppLayouts/Communities/controls/Options.qml +++ b/ui/app/AppLayouts/Communities/controls/Options.qml @@ -13,6 +13,8 @@ Column { property alias requestToJoinEnabled: requestToJoinToggle.checked property alias pinMessagesEnabled: pinMessagesToggle.checked + property alias archiveSupporVisible: archiveSupport.visible + spacing: 0 QtObject { @@ -24,7 +26,7 @@ Column { id: archiveSupport width: parent.width - height: d.optionHeight + height: visible ? d.optionHeight : 0 StatusBaseText { Layout.fillWidth: true diff --git a/ui/app/AppLayouts/Communities/panels/OverviewSettingsPanel.qml b/ui/app/AppLayouts/Communities/panels/OverviewSettingsPanel.qml index af217e6eb6..d32f18b5af 100644 --- a/ui/app/AppLayouts/Communities/panels/OverviewSettingsPanel.qml +++ b/ui/app/AppLayouts/Communities/panels/OverviewSettingsPanel.qml @@ -33,6 +33,7 @@ StackLayout { property bool pinMessagesEnabled property string previousPageName: (currentIndex === 1) ? qsTr("Overview") : "" + property bool archiveSupporVisible: true property bool editable: false property bool owned: false property bool isControlNode: false @@ -190,6 +191,7 @@ StackLayout { options { archiveSupportEnabled: root.archiveSupportEnabled + archiveSupporVisible: root.archiveSupporVisible requestToJoinEnabled: root.requestToJoinEnabled pinMessagesEnabled: root.pinMessagesEnabled } diff --git a/ui/app/AppLayouts/Communities/popups/CreateCommunityPopup.qml b/ui/app/AppLayouts/Communities/popups/CreateCommunityPopup.qml index ebb2d2000b..b608e7d29d 100644 --- a/ui/app/AppLayouts/Communities/popups/CreateCommunityPopup.qml +++ b/ui/app/AppLayouts/Communities/popups/CreateCommunityPopup.qml @@ -442,6 +442,7 @@ StatusStackModal { historyArchiveSupportEnabled: generalViewLayout.options.archiveSupportEnabled, checkedMembership: generalViewLayout.options.requestToJoinEnabled ? Constants.communityChatOnRequestAccess : Constants.communityChatPublicAccess, pinMessagesAllowedForMembers: generalViewLayout.options.pinMessagesEnabled, + archiveSupporVisible: true }, bannerJsonStr: JSON.stringify({imagePath: String(generalViewLayout.bannerPath).replace("file://", ""), cropRect: generalViewLayout.bannerCropRect}) } diff --git a/ui/app/AppLayouts/Communities/views/CommunitySettingsView.qml b/ui/app/AppLayouts/Communities/views/CommunitySettingsView.qml index 53b8e1839f..1095e819a9 100644 --- a/ui/app/AppLayouts/Communities/views/CommunitySettingsView.qml +++ b/ui/app/AppLayouts/Communities/views/CommunitySettingsView.qml @@ -168,6 +168,7 @@ StatusSectionLayout { tags: root.rootStore.communityTags selectedTags: root.filteredSelectedTags archiveSupportEnabled: root.community.historyArchiveSupportEnabled + archiveSupporVisible: root.community.isControlNode requestToJoinEnabled: root.community.access === Constants.communityChatOnRequestAccess pinMessagesEnabled: root.community.pinMessageAllMembersEnabled editable: true diff --git a/vendor/status-go b/vendor/status-go index 42d5d36cf5..631962ce88 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit 42d5d36cf574674d5639cfdfa57810ce2319fa0c +Subproject commit 631962ce88b7f8ba6226f49066f823007726c4cf