Commit ceb6027c authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

UI: contact requests number

Filter out requests for not current account

Change-Id: Ia175d097e9746a93b3e5cadcbb317f749740d0e8
parent 80b1ce11
...@@ -73,6 +73,10 @@ class ContactRequestsViewModel: Stateable, ViewModel { ...@@ -73,6 +73,10 @@ class ContactRequestsViewModel: Stateable, ViewModel {
lazy var hasInvitations: Observable<Bool> = { lazy var hasInvitations: Observable<Bool> = {
return self.contactsService.contactRequests return self.contactsService.contactRequests
.asObservable() .asObservable()
.map({ [unowned self] contactRequests in
return contactRequests
.filter { $0.accountId == self.accountsService.currentAccount?.id }
})
.map({ items in .map({ items in
return !items.isEmpty return !items.isEmpty
}) })
......
...@@ -27,10 +27,18 @@ class ContactRequestTabBarItem: ViewModel, TabBarItemViewModel { ...@@ -27,10 +27,18 @@ class ContactRequestTabBarItem: ViewModel, TabBarItemViewModel {
required init(with injectionBag: InjectionBag) { required init(with injectionBag: InjectionBag) {
let contactService = injectionBag.contactsService let contactService = injectionBag.contactsService
self.itemBadgeValue = contactService.contactRequests.asObservable().map({items in let accountService = injectionBag.accountService
if items.isEmpty { self.itemBadgeValue = contactService.contactRequests
return nil .asObservable()
} .map({ contactRequests in
return "\(items.count)"}) return contactRequests
.filter { $0.accountId == accountService
.currentAccount?.id }
})
.map({items in
if items.isEmpty {
return nil
}
return "\(items.count)"})
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment