feat(communities): Adds mute category interval

Part of: #9369
This commit is contained in:
Boris Melnik 2023-05-30 20:51:57 +03:00
parent e2b3376f66
commit 73eb12c914
8 changed files with 40 additions and 33 deletions

View File

@ -122,11 +122,11 @@ proc init*(self: Controller) =
self.events.on(chat_service.SIGNAL_CHAT_MUTED) do(e:Args):
let args = chat_service.ChatArgs(e)
self.delegate.onChatMuted(args.chatId)
self.delegate.changeMutedOnChat(args.chatId, true)
self.events.on(chat_service.SIGNAL_CHAT_UNMUTED) do(e:Args):
let args = chat_service.ChatArgs(e)
self.delegate.onChatUnmuted(args.chatId)
self.delegate.changeMutedOnChat(args.chatId, false)
self.events.on(message_service.SIGNAL_MESSAGES_MARKED_AS_READ) do(e: Args):
let args = message_service.MessagesMarkedAsReadArgs(e)
@ -597,8 +597,8 @@ proc editCommunity*(
proc exportCommunity*(self: Controller): string =
self.communityService.exportCommunity(self.sectionId)
proc muteCategory*(self: Controller, categoryId: string) =
self.communityService.muteCategory(self.sectionId, categoryId)
proc muteCategory*(self: Controller, categoryId: string, interval: int) =
self.communityService.muteCategory(self.sectionId, categoryId, interval)
proc unmuteCategory*(self: Controller, categoryId: string) =
self.communityService.unmuteCategory(self.sectionId, categoryId)

View File

@ -105,10 +105,7 @@ method onNewMessagesReceived*(self: AccessInterface, sectionIdMsgBelongsTo: stri
chatTypeMsgBelongsTo: ChatType, lastMessageTimestamp: int, unviewedMessagesCount: int, unviewedMentionsCount: int, message: MessageDto) {.base.} =
raise newException(ValueError, "No implementation available")
method onChatMuted*(self: AccessInterface, chatId: string) {.base.} =
raise newException(ValueError, "No implementation available")
method onChatUnmuted*(self: AccessInterface, chatId: string) {.base.} =
method changeMutedOnChat*(self: AccessInterface, chatId: string, muted: bool) {.base.} =
raise newException(ValueError, "No implementation available")
method onMarkAllMessagesRead*(self: AccessInterface, chat: ChatDto) {.base.} =
@ -204,7 +201,7 @@ method muteChat*(self: AccessInterface, chatId: string, interval: int) {.base.}
method unmuteChat*(self: AccessInterface, chatId: string) {.base.} =
raise newException(ValueError, "No implementation available")
method muteCategory*(self: AccessInterface, categoryId: string) {.base.} =
method muteCategory*(self: AccessInterface, categoryId: string, interval: int) {.base.} =
raise newException(ValueError, "No implementation available")
method unmuteCategory*(self: AccessInterface, categoryId: string) {.base.} =

View File

@ -769,8 +769,8 @@ method muteChat*(self: Module, chatId: string, interval: int) =
method unmuteChat*(self: Module, chatId: string) =
self.controller.unmuteChat(chatId)
method muteCategory*(self: Module, categoryId: string) =
self.controller.muteCategory(categoryId)
method muteCategory*(self: Module, categoryId: string, interval: int) =
self.controller.muteCategory(categoryId, interval)
method unmuteCategory*(self: Module, categoryId: string) =
self.controller.unmuteCategory(categoryId)
@ -781,11 +781,8 @@ method onCategoryMuted*(self: Module, categoryId: string) =
method onCategoryUnmuted*(self: Module, categoryId: string) =
self.view.chatsModel().changeMutedOnItemByCategoryId(categoryId, false)
method onChatMuted*(self: Module, chatId: string) =
self.view.chatsModel().changeMutedOnItemById(chatId, muted=true)
method onChatUnmuted*(self: Module, chatId: string) =
self.view.chatsModel().changeMutedOnItemById(chatId, muted=false)
method changeMutedOnChat*(self: Module, chatId: string, muted: bool) =
self.view.chatsModel().changeMutedOnItemById(chatId, muted)
method onCommunityTokenPermissionDeleted*(self: Module, communityId: string, permissionId: string) =
self.rebuildCommunityTokenPermissionsModel()
@ -1175,6 +1172,7 @@ proc addOrUpdateChat(self: Module,
self.updateActiveChatMembership()
if chatExists:
self.changeMutedOnChat(chat.id, chat.muted)
if (chat.chatType == ChatType.PrivateGroupChat):
self.onGroupChatDetailsUpdated(chat.id, chat.name, chat.color, chat.icon)
elif (chat.chatType != ChatType.OneToOne):

View File

@ -200,8 +200,8 @@ QtObject:
proc unmuteChat*(self: View, chatId: string) {.slot.} =
self.delegate.unmuteChat(chatId)
proc muteCategory*(self: View, categoryId: string) {.slot.} =
self.delegate.muteCategory(categoryId)
proc muteCategory*(self: View, categoryId: string, interval: int) {.slot.} =
self.delegate.muteCategory(categoryId, interval)
proc unmuteCategory*(self: View, categoryId: string) {.slot.} =
self.delegate.unmuteCategory(categoryId)

View File

@ -1648,9 +1648,9 @@ QtObject:
error "Error sharing community", msg = e.msg
result = "Error sharing community: " & e.msg
proc muteCategory*(self: Service, communityId: string, categoryId: string) =
proc muteCategory*(self: Service, communityId: string, categoryId: string, interval: int) =
try:
let response = status_go.muteCategory(communityId, categoryId)
let response = status_go.muteCategory(communityId, categoryId, interval)
if (not response.error.isNil):
let msg = response.error.message & " categoryId=" & categoryId
error "error while mute category ", msg

View File

@ -9,13 +9,17 @@ export response_type
proc getCommunityTags*(): RpcResponse[JsonNode] {.raises: [Exception].} =
result = callPrivateRPC("communityTags".prefix)
proc muteCategory*(communityId: string, categoryId: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [communityId, categoryId]
result = callPrivateRPC("muteCommunityCategory".prefix, payload)
proc muteCategory*(communityId: string, categoryId: string, interval: int): RpcResponse[JsonNode] {.raises: [Exception].} =
result = callPrivateRPC("muteCommunityCategory".prefix, %* [
{
"communityId": communityId,
"categoryId": categoryId,
"mutedType": interval,
}
])
proc unmuteCategory*(communityId: string, categoryId: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [communityId, categoryId]
result = callPrivateRPC("unmuteCommunityCategory".prefix, payload)
result = callPrivateRPC("unmuteCommunityCategory".prefix, %* [communityId, categoryId])
proc getCuratedCommunities*(): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* []

View File

@ -14,6 +14,8 @@ import utils 1.0
import shared 1.0
import shared.popups 1.0
import shared.status 1.0
import shared.controls.chat.menuItems 1.0
import "../popups/community"
import "../panels"
import "../panels/communities"
@ -229,18 +231,24 @@ Item {
}
categoryPopupMenu: StatusMenu {
id: contextMenuCategory
property var categoryItem
MuteChatMenuItem {
enabled: !!categoryItem && !categoryItem.muted
title: qsTr("Mute category")
onMuteTriggered: {
root.communitySectionModule.muteCategory(categoryItem.itemId, interval)
contextMenuCategory.close()
}
}
StatusAction {
text: !!categoryItem ? categoryItem.muted ? qsTr("Unmute category") : qsTr("Mute category") : ""
enabled: !!categoryItem && categoryItem.muted
text: qsTr("Unmute category")
icon.name: "notification"
onTriggered: {
if (categoryItem.muted) {
root.communitySectionModule.unmuteCategory(categoryItem.itemId)
} else {
root.communitySectionModule.muteCategory(categoryItem.itemId)
}
root.communitySectionModule.unmuteCategory(categoryItem.itemId)
}
}

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit e8c4b7647f67564c1d2b9534c8487202e91324d7
Subproject commit d73c886d3b093c2018dcf82089dc1b11160ad736