fix(@desktop/chat): the @mention emblem isn't being displayed on the channel list

Fixes #3630
This commit is contained in:
Sale Djenic 2022-02-01 18:12:18 +01:00 committed by saledjenic
parent bf6dbe4815
commit 98293c112b
3 changed files with 22 additions and 16 deletions

View File

@ -331,10 +331,22 @@ method getChatContentModule*(self: Module, chatId: string): QVariant =
return self.chatContentModules[chatId].getModuleAsVariant()
proc updateNotifications(self: Module, chatId: string, unviewedMessagesCount: int, unviewedMentionsCount: int) =
let hasUnreadMessages = unviewedMessagesCount > 0
# update model of this module (appropriate chat from the chats list (chats model))
self.view.chatsModel().updateNotificationsForItemOrSubItemById(chatId, hasUnreadMessages, unviewedMentionsCount)
# update child module
if (self.chatContentModules.contains(chatId)):
self.chatContentModules[chatId].onNotificationsUpdated(hasUnreadMessages, unviewedMentionsCount)
# update parent module
let (sectionHasUnreadMessages, sectionNotificationCount) = self.view.chatsModel().getAllNotifications()
self.delegate.onNotificationsUpdated(self.controller.getMySectionId(), sectionHasUnreadMessages, sectionNotificationCount)
method onActiveSectionChange*(self: Module, sectionId: string) =
if(sectionId != self.controller.getMySectionId()):
return
self.updateNotifications(self.controller.getActiveChatId(), unviewedMessagesCount=0, unviewedMentionsCount=0)
self.delegate.onActiveChatChange(self.controller.getMySectionId(), self.controller.getActiveChatId())
method createPublicChat*(self: Module, chatId: string) =
@ -456,17 +468,6 @@ method createOneToOneChat*(self: Module, chatId: string, ensName: string) =
self.controller.createOneToOneChat(chatId, ensName)
proc updateNotifications(self: Module, chatId: string, unviewedMessagesCount: int, unviewedMentionsCount: int) =
let hasUnreadMessages = unviewedMessagesCount > 0
# update model of this module (appropriate chat from the chats list (chats model))
self.view.chatsModel().updateNotificationsForItemOrSubItemById(chatId, hasUnreadMessages, unviewedMentionsCount)
# update child module
if (self.chatContentModules.contains(chatId)):
self.chatContentModules[chatId].onNotificationsUpdated(hasUnreadMessages, unviewedMentionsCount)
# update parent module
let (sectionHasUnreadMessages, sectionNotificationCount) = self.view.chatsModel().getAllNotifications()
self.delegate.onNotificationsUpdated(self.controller.getMySectionId(), sectionHasUnreadMessages, sectionNotificationCount)
method leaveChat*(self: Module, chatId: string) =
self.controller.leaveChat(chatId)
@ -537,11 +538,10 @@ method onContactDetailsUpdated*(self: Module, publicKey: string) =
method onNewMessagesReceived*(self: Module, chatId: string, unviewedMessagesCount: int, unviewedMentionsCount: int,
messages: seq[MessageDto]) =
let activeChatId = self.controller.getActiveChatId()
if(activeChatId == chatId):
self.controller.markAllMessagesRead(chatId)
else:
self.updateNotifications(chatId, unviewedMessagesCount, unviewedMentionsCount)
if(self.controller.getMySectionId() == self.delegate.getActiveSectionId() and
self.controller.getActiveChatId() == chatId):
return
self.updateNotifications(chatId, unviewedMessagesCount, unviewedMentionsCount)
proc convertPubKeysToJson(self: Module, pubKeys: string): seq[string] =
return map(parseJson(pubKeys).getElems(), proc(x:JsonNode):string = x.getStr)

View File

@ -441,6 +441,9 @@ method emitStoringPasswordError*[T](self: Module[T], errorDescription: string) =
method emitStoringPasswordSuccess*[T](self: Module[T]) =
self.view.emitStoringPasswordSuccess()
method getActiveSectionId*[T](self: Module[T]): string =
return self.controller.getActiveSectionId()
method setActiveSection*[T](self: Module[T], item: SectionItem) =
if(item.isEmpty()):
echo "section is empty and cannot be made as active one"

View File

@ -9,4 +9,7 @@ method onActiveChatChange*(self: AccessInterface, sectionId: string, chatId: str
method onNotificationsUpdated*(self: AccessInterface, sectionId: string, sectionHasUnreadMessages: bool,
sectionNotificationCount: int) {.base.} =
raise newException(ValueError, "No implementation available")
method getActiveSectionId*(self: AccessInterface): string {.base.} =
raise newException(ValueError, "No implementation available")