mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-12 07:14:37 +00:00
fix(pins): fix max 3 pins and unpining pins the new message
Fixes #4576
This commit is contained in:
parent
d43b1eb25c
commit
268d7fcd36
@ -3,6 +3,7 @@ import NimQml, tables, json, re, sequtils, strformat, strutils, chronicles
|
|||||||
import ../../../app/core/tasks/[qt, threadpool]
|
import ../../../app/core/tasks/[qt, threadpool]
|
||||||
import ../../../app/core/signals/types
|
import ../../../app/core/signals/types
|
||||||
import ../../../app/core/eventemitter
|
import ../../../app/core/eventemitter
|
||||||
|
import ../../../app/global/global_singleton
|
||||||
import ../../../backend/messages as status_go
|
import ../../../backend/messages as status_go
|
||||||
import ../contacts/service as contact_service
|
import ../contacts/service as contact_service
|
||||||
import ./dto/message as message_dto
|
import ./dto/message as message_dto
|
||||||
@ -167,12 +168,21 @@ QtObject:
|
|||||||
|
|
||||||
proc handlePinnedMessagesUpdate(self: Service, pinnedMessages: seq[PinnedMessageUpdateDto]) =
|
proc handlePinnedMessagesUpdate(self: Service, pinnedMessages: seq[PinnedMessageUpdateDto]) =
|
||||||
for pm in pinnedMessages:
|
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):
|
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)
|
self.events.emit(SIGNAL_MESSAGE_PINNED, data)
|
||||||
else:
|
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)
|
self.events.emit(SIGNAL_MESSAGE_UNPINNED, data)
|
||||||
|
|
||||||
proc handleDeletedMessagesUpdate(self: Service, deletedMessages: seq[RemovedMessageDto]) =
|
proc handleDeletedMessagesUpdate(self: Service, deletedMessages: seq[RemovedMessageDto]) =
|
||||||
|
@ -211,6 +211,7 @@ ModalPopup {
|
|||||||
onClicked: {
|
onClicked: {
|
||||||
popup.messageStore.unpinMessage(popup.messageToUnpin)
|
popup.messageStore.unpinMessage(popup.messageToUnpin)
|
||||||
popup.messageToUnpin = ""
|
popup.messageToUnpin = ""
|
||||||
|
popup.messageStore.pinMessage(popup.messageToPin)
|
||||||
popup.messageToPin = ""
|
popup.messageToPin = ""
|
||||||
popup.close()
|
popup.close()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user