Skip to content
Snippets Groups Projects
Commit f756586e authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Andreas Traczyk
Browse files

fix: Tab Bar


Fix badge value on Conversation TabBarItem:
- handle case when account does not exists
- filter out messages that shown on contact request conversation

Change-Id: Ife44a70b2d0b728876be648ebad2e3d772128ce5
Reviewed-by: default avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent 743768be
No related branches found
No related tags found
No related merge requests found
...@@ -28,12 +28,18 @@ class ChatTabBarItemViewModel: ViewModel, TabBarItemViewModel { ...@@ -28,12 +28,18 @@ class ChatTabBarItemViewModel: ViewModel, TabBarItemViewModel {
required init(with injectionBag: InjectionBag) { required init(with injectionBag: InjectionBag) {
let accountService = injectionBag.accountService let accountService = injectionBag.accountService
let conversationService = injectionBag.conversationsService let conversationService = injectionBag.conversationsService
let accountHelper = AccountModelHelper(withAccount: accountService.currentAccount!) let contactsService = injectionBag.contactsService
self.itemBadgeValue = { self.itemBadgeValue = {
return conversationService.conversations.map({ conversations in return conversationService.conversations.map({ conversations in
return conversations.map({ conversation in return conversations.map({ conversation in
return conversation.messages.filter({ message in return conversation.messages.filter({ message in
return message.status != .read && message.author != accountHelper.ringId! if let account = accountService.currentAccount {
let accountHelper = AccountModelHelper(withAccount: account)
//filtre out read messages, outgoing messages and messages that are displayed in contactrequest conversation
return message.status != .read && message.author != accountHelper.ringId
&& (contactsService.contactRequest(withRingId: message.author) == nil)
}
return false
}).count }).count
}).reduce(0, +) }).reduce(0, +)
}) })
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment