fix(StatusCommunityMenu): Added mute button

Closes #9694
This commit is contained in:
Alexandra Betouni 2023-04-11 19:48:32 +03:00
parent 1fa8dffe3a
commit 12520214d2
6 changed files with 25 additions and 1 deletions

View File

@ -114,6 +114,9 @@ method onChatUnmuted*(self: AccessInterface, chatId: string) {.base.} =
method onMarkAllMessagesRead*(self: AccessInterface, chat: ChatDto) {.base.} =
raise newException(ValueError, "No implementation available")
method onCommunityMuted*(self: AccessInterface, chatId: string, muted: bool) {.base.} =
raise newException(ValueError, "No implementation available")
method onContactAdded*(self: AccessInterface, publicKey: string) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -258,6 +258,10 @@ proc init*(self: Controller) =
for community in args.communities:
self.delegate.communityEdited(community)
self.events.on(SIGNAL_COMMUNITY_MUTED) do(e:Args):
let args = CommunityMutedArgs(e)
self.delegate.onCommunityMuted(args.communityId, args.muted)
self.events.on(SIGNAL_ENS_RESOLVED) do(e: Args):
var args = ResolvedContactArgs(e)
self.delegate.resolvedENS(args.pubkey, args.address, args.uuid, args.reason)

View File

@ -164,6 +164,9 @@ method communityJoined*(self: AccessInterface, community: CommunityDto, events:
method communityEdited*(self: AccessInterface, community: CommunityDto) {.base.} =
raise newException(ValueError, "No implementation available")
method onCommunityMuted*(self: AccessInterface, communityId: string, muted: bool) {.base.} =
raise newException(ValueError, "No implementation available")
method communityLeft*(self: AccessInterface, communityId: string) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -923,6 +923,12 @@ method communityEdited*[T](
let channelGroup = community.toChannelGroupDto()
self.view.editItem(self.createChannelGroupItem(channelGroup))
method onCommunityMuted*[T](
self: Module[T],
communityId: string,
muted: bool) =
self.view.model.setMuted(communityId, muted)
method getVerificationRequestFrom*[T](self: Module[T], publicKey: string): VerificationRequest =
self.controller.getVerificationRequestFrom(publicKey)

View File

@ -250,6 +250,7 @@ QtObject:
self.countChanged()
proc setMuted*(self: SectionModel, id: string, muted: bool) =
let index = self.getItemIndex(id)
if (index == -1):
return
@ -259,7 +260,6 @@ QtObject:
defer: dataIndex.delete
self.dataChanged(dataIndex, dataIndex, @[ModelRole.Muted.int])
proc editItem*(self: SectionModel, item: SectionItem) =
let index = self.getItemIndex(item.id)
if (index == -1):

View File

@ -338,6 +338,14 @@ Item {
onTriggered: popups.openCommunityProfilePopup(appMain.rootStore, model, communityContextMenu.chatCommunitySectionModule)
}
StatusAction {
text: model.muted ? qsTr("Unmute Community") : qsTr("Mute Community")
icon.name: model.muted ? "notification-muted" : "notification"
onTriggered: {
communityContextMenu.chatCommunitySectionModule.setCommunityMuted(!model.muted)
}
}
StatusMenuSeparator {}
StatusAction {