mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 01:22:46 +02:00
Add alert on error
This commit is contained in:
@@ -44,7 +44,10 @@ final class PollHistoryCoordinator: Coordinator, Presentable {
|
||||
func start() {
|
||||
MXLog.debug("[PollHistoryCoordinator] did start.")
|
||||
pollHistoryViewModel.completion = { [weak self] result in
|
||||
self?.completion?()
|
||||
switch result {
|
||||
case .genericError:
|
||||
self?.showErrorAlert()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,3 +55,15 @@ final class PollHistoryCoordinator: Coordinator, Presentable {
|
||||
pollHistoryHostingController
|
||||
}
|
||||
}
|
||||
|
||||
private extension PollHistoryCoordinator {
|
||||
func showErrorAlert() {
|
||||
let alert = UIAlertController(title: VectorL10n.pollHistoryFetchingError,
|
||||
message: nil,
|
||||
preferredStyle: .alert)
|
||||
|
||||
let cancelAction = UIAlertAction(title: VectorL10n.ok, style: .cancel)
|
||||
alert.addAction(cancelAction)
|
||||
pollHistoryHostingController.present(alert, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ enum PollHistoryConstants {
|
||||
}
|
||||
|
||||
enum PollHistoryViewModelResult: Equatable {
|
||||
#warning("e.g. show poll detail")
|
||||
case genericError
|
||||
}
|
||||
|
||||
// MARK: View
|
||||
|
||||
@@ -70,8 +70,8 @@ private extension PollHistoryViewModel {
|
||||
switch completion {
|
||||
case .finished:
|
||||
break
|
||||
case .failure(_):
|
||||
#warning("Handle errors")
|
||||
case .failure:
|
||||
self.completion?(.genericError)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,13 +86,6 @@ private extension PollHistoryViewModel {
|
||||
}
|
||||
.store(in: &subcriptions)
|
||||
|
||||
pollService
|
||||
.pollErrors
|
||||
.sink { detail in
|
||||
#warning("Handle errors")
|
||||
}
|
||||
.store(in: &subcriptions)
|
||||
|
||||
pollService
|
||||
.fetchedUpTo
|
||||
.weakAssign(to: \.state.syncedUpTo, on: self)
|
||||
|
||||
Reference in New Issue
Block a user