Signal-iOS/SignalServiceKit/MessageBackup/MessageBackupErrorPresenter.swift

52 lines
1.6 KiB
Swift

//
// Copyright 2024 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
//
public protocol MessageBackupErrorPresenterFactory {
func build(
db: any DB,
keyValueStoreFactory: KeyValueStoreFactory,
tsAccountManager: TSAccountManager
) -> MessageBackupErrorPresenter
}
public protocol MessageBackupErrorPresenter {
/// Persist a set of errors for future display.
/// We persist because display may be deferred until certain UI actions occur (finishing registration)
/// during which time the app may be interrupted.
/// We only care to hold onto the latest set of backup errors.
func persistErrors(_ errors: [MessageBackup.CollapsedErrorLog], tx: DBWriteTransaction)
/// Present over the current view controller; calls completion when presentation has finished.
func presentOverTopmostViewController(completion: @escaping () -> Void)
}
public class NoOpMessageBackupErrorPresenterFactory: MessageBackupErrorPresenterFactory {
public init() {}
public func build(
db: any DB,
keyValueStoreFactory: KeyValueStoreFactory,
tsAccountManager: TSAccountManager
) -> MessageBackupErrorPresenter {
return NoOpMessageBackupErrorPresenter()
}
}
public class NoOpMessageBackupErrorPresenter: MessageBackupErrorPresenter {
public init() {}
public func persistErrors(_ errors: [MessageBackup.CollapsedErrorLog], tx: any DBWriteTransaction) {
// do nothing
}
public func presentOverTopmostViewController(completion: @escaping () -> Void) {
// do nothing
}
}