Remove the global UserIndicatorController.alertInfo, replacing it with local alertInfo usage. (#5087)

This commit is contained in:
Doug
2026-02-10 17:16:11 +00:00
committed by GitHub
parent b725d8be80
commit 071a1eeb52
21 changed files with 101 additions and 71 deletions
@@ -199,6 +199,9 @@ enum TimelineAlertInfoType: Hashable {
case sendingFailed
case encryptionAuthenticity(String)
case encryptionForwarder(String)
case inviteAgain
case unableToInvite
case unknown
}
struct RoomMemberState {
@@ -579,7 +579,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
shouldShowInviteAlert
.sink { [weak self] _ in
self?.showInviteAlert()
self?.displayAlert(.inviteAgain)
}
.store(in: &cancellables)
}
@@ -865,19 +865,11 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
// MARK: - Direct chats logics
private func showInviteAlert() {
userIndicatorController.alertInfo = .init(id: .init(),
title: L10n.screenRoomInviteAgainAlertTitle,
message: L10n.screenRoomInviteAgainAlertMessage,
primaryButton: .init(title: L10n.actionInvite) { [weak self] in self?.inviteOtherDMUserBack() },
secondaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil))
}
private let inviteLoadingIndicatorID = UUID().uuidString
private func inviteOtherDMUserBack() {
guard roomProxy.infoPublisher.value.isUserAloneInDirectRoom else {
userIndicatorController.alertInfo = .init(id: .init(), title: L10n.commonError)
displayAlert(.unknown)
return
}
@@ -892,7 +884,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
members.count == 2,
let otherPerson = members.first(where: { $0.userID != roomProxy.ownUserID && $0.membership == .leave })
else {
userIndicatorController.alertInfo = .init(id: .init(), title: L10n.commonError)
displayAlert(.unknown)
return
}
@@ -900,9 +892,7 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
case .success:
break
case .failure:
userIndicatorController.alertInfo = .init(id: .init(),
title: L10n.commonUnableToInviteTitle,
message: L10n.commonUnableToInviteMessage)
displayAlert(.unableToInvite)
}
}
}
@@ -1021,6 +1011,18 @@ class TimelineViewModel: TimelineViewModelType, TimelineViewModelProtocol {
guard let self else { return }
appMediator.open(appSettings.historySharingDetailsURL)
})
case .inviteAgain:
state.bindings.alertInfo = .init(id: .inviteAgain,
title: L10n.screenRoomInviteAgainAlertTitle,
message: L10n.screenRoomInviteAgainAlertMessage,
primaryButton: .init(title: L10n.actionInvite) { [weak self] in self?.inviteOtherDMUserBack() },
secondaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil))
case .unableToInvite:
state.bindings.alertInfo = .init(id: .unableToInvite,
title: L10n.commonUnableToInviteTitle,
message: L10n.commonUnableToInviteMessage)
case .unknown:
state.bindings.alertInfo = .init(id: .unknown, title: L10n.commonError)
}
}