diff --git a/src/app/modules/main/chat_section/controller.nim b/src/app/modules/main/chat_section/controller.nim index 2974a24a19..c240aee77f 100644 --- a/src/app/modules/main/chat_section/controller.nim +++ b/src/app/modules/main/chat_section/controller.nim @@ -42,14 +42,18 @@ method delete*(self: Controller) = discard method init*(self: Controller) = - self.events.on(SIGNAL_CHAT_MUTED) do(e:Args): - let args = ChatArgs(e) + self.events.on(chat_service.SIGNAL_CHAT_MUTED) do(e:Args): + let args = chat_service.ChatArgs(e) self.delegate.onChatMuted(args.chatId) - self.events.on(SIGNAL_CHAT_UNMUTED) do(e:Args): - let args = ChatArgs(e) + self.events.on(chat_service.SIGNAL_CHAT_UNMUTED) do(e:Args): + let args = chat_service.ChatArgs(e) self.delegate.onChatUnmuted(args.chatId) + self.events.on(message_service.SIGNAL_MESSAGES_MARKED_AS_READ) do(e: Args): + let args = message_service.MessagesMarkedAsReadArgs(e) + self.delegate.onMarkAllMessagesRead(args.chatId) + method getMySectionId*(self: Controller): string = return self.sectionId @@ -127,4 +131,7 @@ method muteChat*(self: Controller, chatId: string) = self.chatService.muteChat(chatId) method unmuteChat*(self: Controller, chatId: string) = - self.chatService.unmuteChat(chatId) \ No newline at end of file + self.chatService.unmuteChat(chatId) + +method markAllMessagesRead*(self: Controller, chatId: string) = + self.messageService.markAllMessagesRead(chatId) \ No newline at end of file diff --git a/src/app/modules/main/chat_section/controller_interface.nim b/src/app/modules/main/chat_section/controller_interface.nim index 1d1731e7ad..8c24e1064d 100644 --- a/src/app/modules/main/chat_section/controller_interface.nim +++ b/src/app/modules/main/chat_section/controller_interface.nim @@ -58,4 +58,7 @@ method muteChat*(self: AccessInterface, chatId: string) {.base.} = raise newException(ValueError, "No implementation available") method unmuteChat*(self: AccessInterface, chatId: string) {.base.} = + raise newException(ValueError, "No implementation available") + +method markAllMessagesRead*(self: AccessInterface, chatId: string) {.base.} = raise newException(ValueError, "No implementation available") \ No newline at end of file diff --git a/src/app/modules/main/chat_section/model.nim b/src/app/modules/main/chat_section/model.nim index f1726f9c09..cea7586bfe 100644 --- a/src/app/modules/main/chat_section/model.nim +++ b/src/app/modules/main/chat_section/model.nim @@ -192,3 +192,12 @@ QtObject: var found = false if self.items[i].subItems.muteUnmuteItemById(id, mute): return + + proc setHasUnreadMessage*(self: Model, id: string, value: bool) = + for i in 0 ..< self.items.len: + if(self.items[i].id == id): + let index = self.createIndex(i, 0, nil) + self.items[i].BaseItem.hasUnreadMessages = value + self.dataChanged(index, index, @[ModelRole.HasUnreadMessages.int]) + return + \ No newline at end of file diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index 26ef351877..e45cfd6caa 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -286,7 +286,13 @@ method unmuteChat*(self: Module, chatId: string) = self.controller.unmuteChat(chatId) method onChatMuted*(self: Module, chatId: string) = - self.view.model().muteUnmuteItemOrSubItemById(chatId, true) + self.view.model().muteUnmuteItemOrSubItemById(chatId, mute=true) method onChatUnmuted*(self: Module, chatId: string) = - self.view.model().muteUnmuteItemOrSubItemById(chatId, false) \ No newline at end of file + self.view.model().muteUnmuteItemOrSubItemById(chatId, false) + +method onMarkAllMessagesRead*(self: Module, chatId: string) = + self.view.model().setHasUnreadMessage(chatId, value=false) + +method markAllMessagesRead*(self: Module, chatId: string) = + self.controller.markAllMessagesRead(chatId) \ No newline at end of file diff --git a/src/app/modules/main/chat_section/private_interfaces/module_controller_delegate_interface.nim b/src/app/modules/main/chat_section/private_interfaces/module_controller_delegate_interface.nim index abf9410b7a..936578d79c 100644 --- a/src/app/modules/main/chat_section/private_interfaces/module_controller_delegate_interface.nim +++ b/src/app/modules/main/chat_section/private_interfaces/module_controller_delegate_interface.nim @@ -10,4 +10,7 @@ method onChatMuted*(self: AccessInterface, chatId: string) {.base.} = raise newException(ValueError, "No implementation available") method onChatUnmuted*(self: AccessInterface, chatId: string) {.base.} = + raise newException(ValueError, "No implementation available") + +method onMarkAllMessagesRead*(self: AccessInterface, chatId: string) {.base.} = raise newException(ValueError, "No implementation available") \ No newline at end of file diff --git a/src/app/modules/main/chat_section/private_interfaces/module_view_delegate_interface.nim b/src/app/modules/main/chat_section/private_interfaces/module_view_delegate_interface.nim index f8bd23bdc8..7ed503ef7a 100644 --- a/src/app/modules/main/chat_section/private_interfaces/module_view_delegate_interface.nim +++ b/src/app/modules/main/chat_section/private_interfaces/module_view_delegate_interface.nim @@ -31,4 +31,7 @@ method muteChat*(self: AccessInterface, chatId: string) {.base.} = raise newException(ValueError, "No implementation available") method unmuteChat*(self: AccessInterface, chatId: string) {.base.} = + raise newException(ValueError, "No implementation available") + +method markAllMessagesRead*(self: AccessInterface, chatId: string) {.base.} = raise newException(ValueError, "No implementation available") \ No newline at end of file diff --git a/src/app/modules/main/chat_section/view.nim b/src/app/modules/main/chat_section/view.nim index 4edcb3ae7e..584e2fb36d 100644 --- a/src/app/modules/main/chat_section/view.nim +++ b/src/app/modules/main/chat_section/view.nim @@ -103,4 +103,7 @@ QtObject: self.delegate.muteChat(chatId) proc unmuteChat*(self: View, chatId: string) {.slot.} = - self.delegate.unmuteChat(chatId) \ No newline at end of file + self.delegate.unmuteChat(chatId) + + proc markAllMessagesRead*(self: View, chatId: string) {.slot.} = + self.delegate.markAllMessagesRead(chatId) \ No newline at end of file diff --git a/src/app_service/service/message/service.nim b/src/app_service/service/message/service.nim index 7c0de42822..c4cb8cc078 100644 --- a/src/app_service/service/message/service.nim +++ b/src/app_service/service/message/service.nim @@ -41,7 +41,7 @@ type chatId*: string messageId*: string - MessagesMarkedAsReadArgs = ref object of Args + MessagesMarkedAsReadArgs* = ref object of Args chatId*: string allMessagesMarked*: bool messagesIds*: seq[string] diff --git a/ui/app/AppLayouts/Chat/views/ChatContextMenuView.qml b/ui/app/AppLayouts/Chat/views/ChatContextMenuView.qml index 38933d2a43..4661ed1c98 100644 --- a/ui/app/AppLayouts/Chat/views/ChatContextMenuView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatContextMenuView.qml @@ -25,7 +25,7 @@ StatusPopupMenu { signal requestAllHistoricMessages(string id) signal unmuteChat(string id) signal muteChat(string id) - signal markAsRead(string id) + signal markAllMessagesRead(string id) signal clearChatHistory(string id) signal editChannel(string id) signal downloadMessages(string file) @@ -112,7 +112,7 @@ StatusPopupMenu { icon.name: "checkmark-circle" enabled: root.chatType !== Constants.chatType.privateGroupChat onTriggered: { - root.markAsRead(root.chatId) + root.markAllMessagesRead(root.chatId) } // Will be deleted later diff --git a/ui/app/AppLayouts/Chat/views/CommunityColumnView.qml b/ui/app/AppLayouts/Chat/views/CommunityColumnView.qml index 080bac16c7..9bfe4f6d11 100644 --- a/ui/app/AppLayouts/Chat/views/CommunityColumnView.qml +++ b/ui/app/AppLayouts/Chat/views/CommunityColumnView.qml @@ -284,6 +284,10 @@ Item { onUnmuteChat: { root.communitySectionModule.unmuteChat(id) } + + onMarkAllMessagesRead: { + root.communitySectionModule.markAllMessagesRead(id) + } } } diff --git a/ui/app/AppLayouts/Chat/views/ContactsColumnView.qml b/ui/app/AppLayouts/Chat/views/ContactsColumnView.qml index bbdc605da7..bccf94962e 100644 --- a/ui/app/AppLayouts/Chat/views/ContactsColumnView.qml +++ b/ui/app/AppLayouts/Chat/views/ContactsColumnView.qml @@ -283,6 +283,10 @@ Item { onUnmuteChat: { root.chatSectionModule.unmuteChat(id) } + + onMarkAllMessagesRead: { + root.chatSectionModule.markAllMessagesRead(id) + } } }