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 {
lazy var hasInvitations: Observable<Bool> = {
return self.contactsService.contactRequests
.asObservable()
.map({ [unowned self] contactRequests in
return contactRequests
.filter { $0.accountId == self.accountsService.currentAccount?.id }
})
.map({ items in
return !items.isEmpty
})
......
......@@ -27,7 +27,15 @@ class ContactRequestTabBarItem: ViewModel, TabBarItemViewModel {
required init(with injectionBag: InjectionBag) {
let contactService = injectionBag.contactsService
self.itemBadgeValue = contactService.contactRequests.asObservable().map({items in
let accountService = injectionBag.accountService
self.itemBadgeValue = contactService.contactRequests
.asObservable()
.map({ contactRequests in
return contactRequests
.filter { $0.accountId == accountService
.currentAccount?.id }
})
.map({items in
if items.isEmpty {
return nil
}
......
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