diff --git a/src/app/modules/main/chat_section/controller.nim b/src/app/modules/main/chat_section/controller.nim index 3e0c496be1..bae6d4cefa 100644 --- a/src/app/modules/main/chat_section/controller.nim +++ b/src/app/modules/main/chat_section/controller.nim @@ -636,8 +636,8 @@ proc muteCategory*(self: Controller, categoryId: string, interval: int) = proc unmuteCategory*(self: Controller, categoryId: string) = self.communityService.unmuteCategory(self.sectionId, categoryId) -proc setCommunityMuted*(self: Controller, muted: bool) = - self.communityService.setCommunityMuted(self.sectionId, muted) +proc setCommunityMuted*(self: Controller, mutedType: int) = + self.communityService.setCommunityMuted(self.sectionId, mutedType) proc inviteUsersToCommunity*(self: Controller, pubKeys: string, inviteMessage: string): string = result = self.communityService.inviteUsersToCommunityById(self.sectionId, pubKeys, inviteMessage) diff --git a/src/app/modules/main/chat_section/io_interface.nim b/src/app/modules/main/chat_section/io_interface.nim index 13bf16ab69..79d16dcc90 100644 --- a/src/app/modules/main/chat_section/io_interface.nim +++ b/src/app/modules/main/chat_section/io_interface.nim @@ -304,7 +304,7 @@ method unbanUserFromCommunity*(self: AccessInterface, pubKey: string) {.base.} = method exportCommunity*(self: AccessInterface): string {.base.} = raise newException(ValueError, "No implementation available") -method setCommunityMuted*(self: AccessInterface, muted: bool) {.base.} = +method setCommunityMuted*(self: AccessInterface, mutedType: int) {.base.} = raise newException(ValueError, "No implementation available") method inviteUsersToCommunity*(self: AccessInterface, pubKeysJSON: string, inviteMessage: string): string {.base.} = diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index 270c13ab5d..830c7342ba 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -1164,8 +1164,8 @@ method editCommunity*(self: Module, name: string, method exportCommunity*(self: Module): string = self.controller.exportCommunity() -method setCommunityMuted*(self: Module, muted: bool) = - self.controller.setCommunityMuted(muted) +method setCommunityMuted*(self: Module, mutedType: int) = + self.controller.setCommunityMuted(mutedType) method inviteUsersToCommunity*(self: Module, pubKeysJSON: string, inviteMessage: string): string = result = self.controller.inviteUsersToCommunity(pubKeysJSON, inviteMessage) diff --git a/src/app/modules/main/chat_section/view.nim b/src/app/modules/main/chat_section/view.nim index 33df9ebca3..a7031ab1dd 100644 --- a/src/app/modules/main/chat_section/view.nim +++ b/src/app/modules/main/chat_section/view.nim @@ -324,8 +324,8 @@ QtObject: proc exportCommunity*(self: View): string {.slot.} = self.delegate.exportCommunity() - proc setCommunityMuted*(self: View, muted: bool) {.slot.} = - self.delegate.setCommunityMuted(muted) + proc setCommunityMuted*(self: View, mutedType: int) {.slot.} = + self.delegate.setCommunityMuted(mutedType) proc inviteUsersToCommunity*(self: View, pubKeysJSON: string, inviteMessage: string): string {.slot.} = result = self.delegate.inviteUsersToCommunity(pubKeysJSON, inviteMessage) diff --git a/src/app/modules/main/communities/controller.nim b/src/app/modules/main/communities/controller.nim index b65fb83607..e605657caf 100644 --- a/src/app/modules/main/communities/controller.nim +++ b/src/app/modules/main/communities/controller.nim @@ -210,8 +210,8 @@ proc requestCommunityInfo*(self: Controller, communityId: string, importing: boo proc importCommunity*(self: Controller, communityKey: string) = self.communityService.importCommunity(communityKey) -proc setCommunityMuted*(self: Controller, communityId: string, muted: bool) = - self.communityService.setCommunityMuted(communityId, muted) +proc setCommunityMuted*(self: Controller, communityId: string, mutedType: int) = + self.communityService.setCommunityMuted(communityId, mutedType) proc getContactNameAndImage*(self: Controller, contactId: string): tuple[name: string, image: string, largeImage: string] = diff --git a/src/app/modules/main/profile_section/communities/controller.nim b/src/app/modules/main/profile_section/communities/controller.nim index 8c196d6e29..37052bb4da 100644 --- a/src/app/modules/main/profile_section/communities/controller.nim +++ b/src/app/modules/main/profile_section/communities/controller.nim @@ -23,6 +23,6 @@ proc inviteUsersToCommunity*(self: Controller, communityID: string, pubKeys: str proc leaveCommunity*(self: Controller, communityID: string) = self.communityService.leaveCommunity(communityID) -method setCommunityMuted*(self: Controller, communityID: string, muted: bool) = - self.communityService.setCommunityMuted(communityID, muted) +method setCommunityMuted*(self: Controller, communityID: string, mutedType: int) = + self.communityService.setCommunityMuted(communityID, mutedType) diff --git a/src/app/modules/main/profile_section/communities/io_interface.nim b/src/app/modules/main/profile_section/communities/io_interface.nim index fff775653b..05c84d6367 100644 --- a/src/app/modules/main/profile_section/communities/io_interface.nim +++ b/src/app/modules/main/profile_section/communities/io_interface.nim @@ -28,6 +28,6 @@ method inviteUsersToCommunity*(self: AccessInterface, communityID: string, pubKe method leaveCommunity*(self: AccessInterface, communityID: string) {.base.} = raise newException(ValueError, "No implementation available") -method setCommunityMuted*(self: AccessInterface, communityID: string, muted: bool) {.base.} = +method setCommunityMuted*(self: AccessInterface, communityID: string, mutedType: int) {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/profile_section/communities/module.nim b/src/app/modules/main/profile_section/communities/module.nim index 50bda1e40f..29675c90e4 100644 --- a/src/app/modules/main/profile_section/communities/module.nim +++ b/src/app/modules/main/profile_section/communities/module.nim @@ -48,5 +48,5 @@ method inviteUsersToCommunity*(self: Module, communityID: string, pubKeysJSON: s method leaveCommunity*(self: Module, communityID: string) = self.controller.leaveCommunity(communityID) -method setCommunityMuted*(self: Module, communityID: string, muted: bool) = - self.controller.setCommunityMuted(communityID, muted) +method setCommunityMuted*(self: Module, communityID: string, mutedType: int) = + self.controller.setCommunityMuted(communityID, mutedType) diff --git a/src/app/modules/main/profile_section/communities/view.nim b/src/app/modules/main/profile_section/communities/view.nim index 6b79dd3eb8..6f9f030a8c 100644 --- a/src/app/modules/main/profile_section/communities/view.nim +++ b/src/app/modules/main/profile_section/communities/view.nim @@ -25,5 +25,5 @@ QtObject: method leaveCommunity*(self: View, communityID: string) {.slot.} = self.delegate.leaveCommunity(communityID) - method setCommunityMuted*(self: View, communityID: string, muted: bool) {.slot.} = - self.delegate.setCommunityMuted(communityID, muted) \ No newline at end of file + method setCommunityMuted*(self: View, communityID: string, mutedType: int) {.slot.} = + self.delegate.setCommunityMuted(communityID, mutedType) \ No newline at end of file diff --git a/src/app_service/service/community/dto/community.nim b/src/app_service/service/community/dto/community.nim index d67ccc763c..0aae6a9002 100644 --- a/src/app_service/service/community/dto/community.nim +++ b/src/app_service/service/community/dto/community.nim @@ -16,6 +16,15 @@ type RequestToJoinType* {.pure.}= enum Accepted = 3, Canceled = 4 +type MutedType* {.pure.}= enum + For15min = 1, + For1hr = 2, + For8hr = 3, + For1week = 4, + TillUnmuted = 5, + For1min = 6, + Unmuted = 7 + type CommunityMembershipRequestDto* = object id*: string publicKey*: string diff --git a/src/app_service/service/community/service.nim b/src/app_service/service/community/service.nim index 2aa502f8b3..d505682014 100644 --- a/src/app_service/service/community/service.nim +++ b/src/app_service/service/community/service.nim @@ -1813,10 +1813,14 @@ QtObject: except Exception as e: error "Error banning user from community", msg = e.msg - proc setCommunityMuted*(self: Service, communityId: string, muted: bool) = + proc setCommunityMuted*(self: Service, communityId: string, mutedType: int) = try: - discard status_go.setCommunityMuted(communityId, muted) - + let response = status_go.setCommunityMuted(communityId, mutedType) + if not response.error.isNil: + error "error muting the community", msg = response.error.message + return + + let muted = if (MutedType(mutedType) == MutedType.Unmuted): false else: true self.events.emit(SIGNAL_COMMUNITY_MUTED, CommunityMutedArgs(communityId: communityId, muted: muted)) except Exception as e: diff --git a/src/backend/communities.nim b/src/backend/communities.nim index b1d6bcff41..52c798390a 100644 --- a/src/backend/communities.nim +++ b/src/backend/communities.nim @@ -370,8 +370,11 @@ proc unbanUserFromCommunity*(communityId: string, pubKey: string): RpcResponse[J "user": pubKey }]) -proc setCommunityMuted*(communityId: string, muted: bool): RpcResponse[JsonNode] {.raises: [Exception].} = - return callPrivateRPC("setCommunityMuted".prefix, %*[communityId, muted]) +proc setCommunityMuted*(communityId: string, mutedType: int): RpcResponse[JsonNode] {.raises: [Exception].} = + return callPrivateRPC("setCommunityMuted".prefix, %*[{ + "communityId": communityId, + "mutedType": mutedType + }]) proc inviteUsersToCommunity*(communityId: string, pubKeys: seq[string]): RpcResponse[JsonNode] {.raises: [Exception].} = return callPrivateRPC("inviteUsersToCommunity".prefix, %*[{ diff --git a/ui/app/AppLayouts/Profile/panels/CommunitiesListPanel.qml b/ui/app/AppLayouts/Profile/panels/CommunitiesListPanel.qml index eccf1f1f4e..622ce1c762 100644 --- a/ui/app/AppLayouts/Profile/panels/CommunitiesListPanel.qml +++ b/ui/app/AppLayouts/Profile/panels/CommunitiesListPanel.qml @@ -9,15 +9,20 @@ import StatusQ.Popups 0.1 import utils 1.0 +import shared.controls.chat.menuItems 1.0 + StatusListView { id: root property bool hasAddedContacts: false signal inviteFriends(var communityData) + signal closeCommunityClicked(string communityId) signal leaveCommunityClicked(string community, string communityId, string outroMessage) - signal setCommunityMutedClicked(string communityId, bool muted) + + signal setCommunityMutedClicked(string communityId, int mutedType) + signal setActiveCommunityClicked(string communityId) interactive: false @@ -43,27 +48,50 @@ StatusListView { onClicked: setActiveCommunityClicked(model.id) components: [ - StatusFlatButton { - anchors.verticalCenter: parent.verticalCenter - objectName: "CommunitiesListPanel_leaveCommunityPopupButton" - size: StatusBaseButton.Size.Small - type: StatusBaseButton.Type.Danger - borderColor: "transparent" - enabled: model.memberRole !== Constants.memberRole.owner - text: model.spectated ? qsTr("Close Community") : qsTr("Leave Community") - onClicked: model.spectated ? root.closeCommunityClicked(model.id) : root.leaveCommunityClicked(model.name, model.id, model.outroMessage) - }, + StatusFlatButton { anchors.verticalCenter: parent.verticalCenter size: StatusBaseButton.Size.Small - icon.name: model.muted ? "notification-muted" : "notification" - onClicked: root.setCommunityMutedClicked(model.id, !model.muted) - }, - StatusFlatButton { - anchors.verticalCenter: parent.verticalCenter - size: StatusBaseButton.Size.Small - icon.name: "invite-users" - onClicked: root.inviteFriends(model) + icon.name: "dots-icon" + onClicked: menu.popup(0, height) + + property StatusMenu menu: StatusMenu { + id: communityContextMenu + width: 180 + + StatusAction { + text: qsTr("Invite People") + icon.name: "share-ios" + enabled: model.canManageUsers + onTriggered: root.inviteFriends(model) + } + + MuteChatMenuItem { + enabled: !model.muted + title: qsTr("Mute Community") + onMuteTriggered: { + root.setCommunityMutedClicked(model.id, interval) + communityContextMenu.close() + } + } + + StatusAction { + enabled: model.muted + text: qsTr("Unmute Community") + icon.name: "notification-muted" + onTriggered: root.setCommunityMutedClicked(model.id, Constants.MutingVariations.Unmuted) + } + + StatusMenuSeparator {} + + StatusAction { + text: model.spectated ? qsTr("Close Community") : qsTr("Leave Community") + icon.name: "arrow-left" + type: StatusAction.Type.Danger + onTriggered: model.spectated ? root.closeCommunityClicked(model.id) + : root.leaveCommunityClicked(model.name, model.id, model.outroMessage) + } + } } ] } diff --git a/ui/app/AppLayouts/Profile/views/CommunitiesView.qml b/ui/app/AppLayouts/Profile/views/CommunitiesView.qml index e214379b20..a2a4dd3923 100644 --- a/ui/app/AppLayouts/Profile/views/CommunitiesView.qml +++ b/ui/app/AppLayouts/Profile/views/CommunitiesView.qml @@ -124,7 +124,7 @@ SettingsContentBase { } onSetCommunityMutedClicked: { - root.profileSectionStore.communitiesProfileModule.setCommunityMuted(communityId, muted) + root.profileSectionStore.communitiesProfileModule.setCommunityMuted(communityId, mutedType) } onSetActiveCommunityClicked: { diff --git a/ui/app/mainui/AppMain.qml b/ui/app/mainui/AppMain.qml index 587bae47d1..50e26523a9 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -17,6 +17,7 @@ import AppLayouts.CommunitiesPortal 1.0 import utils 1.0 import shared 1.0 import shared.controls 1.0 +import shared.controls.chat.menuItems 1.0 import shared.panels 1.0 import shared.popups 1.0 import shared.popups.keycard 1.0 @@ -327,7 +328,7 @@ Item { popupMenu: Component { StatusMenu { id: communityContextMenu - + width: 180 property var chatCommunitySectionModule openHandler: function () { @@ -356,11 +357,21 @@ Item { StatusMenuSeparator {} + MuteChatMenuItem { + enabled: !model.muted + title: qsTr("Mute Community") + onMuteTriggered: { + communityContextMenu.chatCommunitySectionModule.setCommunityMuted(interval) + communityContextMenu.close() + } + } + StatusAction { - text: model.muted ? qsTr("Unmute Community") : qsTr("Mute Community") - icon.name: model.muted ? "notification-muted" : "notification" + enabled: model.muted + text: qsTr("Unmute Community") + icon.name: "notification-muted" onTriggered: { - communityContextMenu.chatCommunitySectionModule.setCommunityMuted(!model.muted) + communityContextMenu.chatCommunitySectionModule.setCommunityMuted(Constants.MutingVariations.Unmuted) } } diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index 613864bf92..d1ae7e6e81 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -1078,6 +1078,7 @@ QtObject { For8hr = 3, For1week = 4, TillUnmuted = 5, - For1min = 6 + For1min = 6, + Unmuted = 7 } } diff --git a/vendor/status-go b/vendor/status-go index ea7a389075..3e7d1a5f34 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit ea7a3890755b25856ec8f8da7bdda0189a3fcc68 +Subproject commit 3e7d1a5f34183ea9f2ebf3b3d6a8143c98674d62