mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Add invites badges (#819)
This commit is contained in:
@@ -70,6 +70,7 @@ struct HomeScreenViewState: BindableState {
|
||||
let invitePermalink: URL?
|
||||
|
||||
var hasPendingInvitations = false
|
||||
var hasUnreadPendingInvitations = false
|
||||
|
||||
var startChatFlowEnabled: Bool {
|
||||
ServiceLocator.shared.settings.startChatFlowEnabled
|
||||
|
||||
@@ -134,10 +134,18 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
invitesSummaryProvider.countPublisher
|
||||
.map { $0 > 0 }
|
||||
invitesSummaryProvider.roomListPublisher
|
||||
.combineLatest(ServiceLocator.shared.settings.$seenInvites)
|
||||
.receive(on: DispatchQueue.main)
|
||||
.weakAssign(to: \.state.hasPendingInvitations, on: self)
|
||||
.sink { [weak self] summaries, readInvites in
|
||||
self?.state.hasPendingInvitations = !summaries.isEmpty
|
||||
self?.state.hasUnreadPendingInvitations = summaries.contains(where: {
|
||||
guard let roomId = $0.id else {
|
||||
return false
|
||||
}
|
||||
return !readInvites.contains(roomId)
|
||||
})
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
updateRooms()
|
||||
|
||||
@@ -33,7 +33,7 @@ struct HomeScreen: View {
|
||||
}
|
||||
|
||||
if context.viewState.hasPendingInvitations, ServiceLocator.shared.settings.invitesFlowEnabled {
|
||||
HomeScreenInvitesButton(title: L10n.actionInvitesList, hasBadge: true) {
|
||||
HomeScreenInvitesButton(title: L10n.actionInvitesList, hasBadge: context.viewState.hasUnreadPendingInvitations) {
|
||||
context.send(viewAction: .selectInvites)
|
||||
}
|
||||
.padding(.trailing, 16)
|
||||
|
||||
Reference in New Issue
Block a user