feat(@desktop/general): contacts requests participates in calculating count badge for `Chat` section
This commit is contained in:
parent
00156cc9c0
commit
3a25f8d1c8
|
@ -342,6 +342,13 @@ method getChatContentModule*(self: Module, chatId: string): QVariant =
|
|||
|
||||
return self.chatContentModules[chatId].getModuleAsVariant()
|
||||
|
||||
proc updateParentNotifications(self: Module) =
|
||||
var (sectionHasUnreadMessages, sectionNotificationCount) = self.view.chatsModel().getAllNotifications()
|
||||
if(not self.controller.isCommunity()):
|
||||
sectionNotificationCount += self.view.contactRequestsModel().getCount()
|
||||
sectionHasUnreadMessages = sectionHasUnreadMessages or sectionNotificationCount > 0
|
||||
self.delegate.onNotificationsUpdated(self.controller.getMySectionId(), sectionHasUnreadMessages, sectionNotificationCount)
|
||||
|
||||
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))
|
||||
|
@ -350,8 +357,7 @@ proc updateNotifications(self: Module, chatId: string, unviewedMessagesCount: in
|
|||
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)
|
||||
self.updateParentNotifications()
|
||||
|
||||
method onActiveSectionChange*(self: Module, sectionId: string) =
|
||||
if(sectionId != self.controller.getMySectionId()):
|
||||
|
@ -558,6 +564,7 @@ method acceptContactRequest*(self: Module, publicKey: string) =
|
|||
|
||||
method onContactAccepted*(self: Module, publicKey: string) =
|
||||
self.view.contactRequestsModel().removeItemWithPubKey(publicKey)
|
||||
self.updateParentNotifications()
|
||||
|
||||
method acceptAllContactRequests*(self: Module) =
|
||||
let pubKeys = self.view.contactRequestsModel().getPublicKeys()
|
||||
|
@ -569,6 +576,7 @@ method rejectContactRequest*(self: Module, publicKey: string) =
|
|||
|
||||
method onContactRejected*(self: Module, publicKey: string) =
|
||||
self.view.contactRequestsModel().removeItemWithPubKey(publicKey)
|
||||
self.updateParentNotifications()
|
||||
|
||||
method rejectAllContactRequests*(self: Module) =
|
||||
let pubKeys = self.view.contactRequestsModel().getPublicKeys()
|
||||
|
@ -593,6 +601,7 @@ method onContactDetailsUpdated*(self: Module, publicKey: string) =
|
|||
not self.view.contactRequestsModel().containsItemWithPubKey(publicKey)):
|
||||
let item = self.createItemFromPublicKey(publicKey)
|
||||
self.view.contactRequestsModel().addItem(item)
|
||||
self.updateParentNotifications()
|
||||
|
||||
let (chatName, chatImage, isIdenticon) = self.controller.getOneToOneChatNameAndImage(publicKey)
|
||||
self.view.chatsModel().updateItemDetails(publicKey, chatName, chatImage, isIdenticon)
|
||||
|
|
|
@ -243,6 +243,9 @@ method setUserStatus*(self: Controller, status: bool) =
|
|||
method getContact*(self: Controller, id: string): ContactsDto =
|
||||
return self.contactsService.getContactById(id)
|
||||
|
||||
method getContacts*(self: Controller): seq[ContactsDto] =
|
||||
return self.contactsService.getContacts()
|
||||
|
||||
method getContactNameAndImage*(self: Controller, contactId: string):
|
||||
tuple[name: string, image: string, isIdenticon: bool] =
|
||||
return self.contactsService.getContactNameAndImage(contactId)
|
||||
|
|
|
@ -41,6 +41,9 @@ method setUserStatus*(self: AccessInterface, status: bool) {.base.} =
|
|||
method getContact*(self: AccessInterface, id: string): ContactsDto {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getContacts*(self: AccessInterface): seq[ContactsDto] {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getContactNameAndImage*(self: AccessInterface, contactId: string):
|
||||
tuple[name: string, image: string, isIdenticon: bool] {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
|
|
@ -256,9 +256,10 @@ method load*[T](
|
|||
var activeSectionId = singletonInstance.localAccountSensitiveSettings.getActiveSection()
|
||||
|
||||
# Chat Section
|
||||
let receivedContactRequests = self.controller.getContacts().filter(x => x.requestReceived() and not x.isContact() and not x.isBlocked())
|
||||
let (unviewedCount, mentionsCount) = self.controller.getNumOfNotificaitonsForChat()
|
||||
let hasNotification = unviewedCount > 0 or mentionsCount > 0
|
||||
let notificationsCount = mentionsCount
|
||||
let notificationsCount = mentionsCount + receivedContactRequests.len
|
||||
let hasNotification = unviewedCount > 0 or notificationsCount > 0
|
||||
let chatSectionItem = initItem(conf.CHAT_SECTION_ID, SectionType.Chat, conf.CHAT_SECTION_NAME,
|
||||
amISectionAdmin = false,
|
||||
description = "",
|
||||
|
|
|
@ -27,7 +27,7 @@ QtObject:
|
|||
result.setup
|
||||
|
||||
proc countChanged(self: Model) {.signal.}
|
||||
proc getCount(self: Model): int {.slot.} =
|
||||
proc getCount*(self: Model): int {.slot.} =
|
||||
self.items.len
|
||||
QtProperty[int] count:
|
||||
read = getCount
|
||||
|
|
|
@ -141,13 +141,13 @@ QtObject:
|
|||
return toSeq(self.contacts.values)
|
||||
|
||||
proc getAddedContacts*(self: Service): seq[ContactsDto] =
|
||||
return self.getContacts().filter(x => x.added)
|
||||
return self.getContacts().filter(x => x.isContact())
|
||||
|
||||
proc getBlockedContacts*(self: Service): seq[ContactsDto] =
|
||||
return self.getContacts().filter(x => x.blocked)
|
||||
return self.getContacts().filter(x => x.isBlocked())
|
||||
|
||||
proc getContactsWhoAddedMe*(self: Service): seq[ContactsDto] =
|
||||
return self.getContacts().filter(x => x.hasAddedUs)
|
||||
return self.getContacts().filter(x => x.requestReceived())
|
||||
|
||||
proc fetchContact(self: Service, id: string): ContactsDto =
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue