From 781ec30e7ff3087407006ef69ea0c12149affdf5 Mon Sep 17 00:00:00 2001 From: Patryk Osmaczko Date: Wed, 17 Aug 2022 18:58:15 +0200 Subject: [PATCH] feat(@desktop/chat): update lastMessageTimestamp on message sent iterates: #6634 --- src/app/modules/main/chat_section/controller.nim | 4 ++++ src/app/modules/main/chat_section/io_interface.nim | 3 +++ src/app/modules/main/chat_section/module.nim | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/app/modules/main/chat_section/controller.nim b/src/app/modules/main/chat_section/controller.nim index c472040eb6..7e51e9fe60 100644 --- a/src/app/modules/main/chat_section/controller.nim +++ b/src/app/modules/main/chat_section/controller.nim @@ -61,6 +61,10 @@ proc getActiveChatId*(self: Controller): string = proc init*(self: Controller) = + self.events.on(SIGNAL_SENDING_SUCCESS) do(e:Args): + let args = MessageSendingSuccess(e) + self.delegate.updateLastMessageTimestamp(args.chat.id, args.chat.timestamp.int) + self.events.on(SIGNAL_NEW_MESSAGE_RECEIVED) do(e: Args): let args = MessagesArgs(e) if (self.sectionId != args.sectionId or args.messages.len == 0): diff --git a/src/app/modules/main/chat_section/io_interface.nim b/src/app/modules/main/chat_section/io_interface.nim index 7b266014a8..abf47a8c45 100644 --- a/src/app/modules/main/chat_section/io_interface.nim +++ b/src/app/modules/main/chat_section/io_interface.nim @@ -310,3 +310,6 @@ method onMeMentionedInEditedMessage*(self: AccessInterface, chatId: string, edit method downloadMessages*(self: AccessInterface, chatId: string, filePath: string) = raise newException(ValueError, "No implementation available") + +method updateLastMessageTimestamp*(self: AccessInterface, chatId: string, lastMessageTimestamp: int) = + raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index 633790a8f0..7f73a14920 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -363,7 +363,7 @@ proc updateBadgeNotifications(self: Module, chatId: string, hasUnreadMessages: b # update parent module self.updateParentBadgeNotifications() -proc updateLastMessageTimestamp(self: Module, chatId: string, lastMessageTimestamp: int) = +method updateLastMessageTimestamp*(self: Module, chatId: string, lastMessageTimestamp: int) = self.view.chatsModel().updateLastMessageTimestampForItemById(chatId, lastMessageTimestamp) method onActiveSectionChange*(self: Module, sectionId: string) =