diff --git a/src/app_service/service/message/service.nim b/src/app_service/service/message/service.nim index 47f0e5b28d..868d07af51 100644 --- a/src/app_service/service/message/service.nim +++ b/src/app_service/service/message/service.nim @@ -3,6 +3,7 @@ import NimQml, tables, json, re, sequtils, strformat, strutils, chronicles import ../../../app/core/tasks/[qt, threadpool] import ../../../app/core/signals/types import ../../../app/core/eventemitter +import ../../../app/global/global_singleton import ../../../backend/messages as status_go import ../contacts/service as contact_service import ./dto/message as message_dto @@ -167,12 +168,21 @@ QtObject: proc handlePinnedMessagesUpdate(self: Service, pinnedMessages: seq[PinnedMessageUpdateDto]) = for pm in pinnedMessages: - let data = MessagePinUnpinArgs(chatId: pm.chatId, messageId: pm.messageId, actionInitiatedBy: pm.pinnedBy) + var chatId: string = "" + if (self.numOfPinnedMessagesPerChat.contains(pm.localChatId)): + # In 1-1 chats, the message's chatId is the localChatId + chatId = pm.localChatId + elif (self.numOfPinnedMessagesPerChat.contains(pm.chatId)): + chatId = pm.chatId + + let data = MessagePinUnpinArgs(chatId: chatId, messageId: pm.messageId, actionInitiatedBy: pm.pinnedBy) if(pm.pinned): - self.numOfPinnedMessagesPerChat[pm.chatId] = self.getNumOfPinnedMessages(pm.chatId) + 1 + if (chatId != "" and pm.pinnedBy != singletonInstance.userProfile.getPubKey()): + self.numOfPinnedMessagesPerChat[chatId] = self.getNumOfPinnedMessages(chatId) + 1 self.events.emit(SIGNAL_MESSAGE_PINNED, data) else: - self.numOfPinnedMessagesPerChat[pm.chatId] = self.getNumOfPinnedMessages(pm.chatId) - 1 + if (chatId != "" and pm.pinnedBy != singletonInstance.userProfile.getPubKey()): + self.numOfPinnedMessagesPerChat[chatId] = self.getNumOfPinnedMessages(chatId) - 1 self.events.emit(SIGNAL_MESSAGE_UNPINNED, data) proc handleDeletedMessagesUpdate(self: Service, deletedMessages: seq[RemovedMessageDto]) = diff --git a/ui/app/AppLayouts/Chat/popups/PinnedMessagesPopup.qml b/ui/app/AppLayouts/Chat/popups/PinnedMessagesPopup.qml index a535f9f2ee..765f77e7c6 100644 --- a/ui/app/AppLayouts/Chat/popups/PinnedMessagesPopup.qml +++ b/ui/app/AppLayouts/Chat/popups/PinnedMessagesPopup.qml @@ -211,6 +211,7 @@ ModalPopup { onClicked: { popup.messageStore.unpinMessage(popup.messageToUnpin) popup.messageToUnpin = "" + popup.messageStore.pinMessage(popup.messageToPin) popup.messageToPin = "" popup.close() }