Handles single and multiple sync failures

If a single sync failure is encountered a sheet is presented which allows the user to update their credentials.

If multiple sync failures are encountered an alert is shown listing the accounts which encountered errors. On iOS, this alert can take the user into Settings, but there is no obvious way to programatically pesent macOS preferences.
This commit is contained in:
Stuart Breckenridge
2020-07-25 16:40:04 +08:00
parent 75b9264d44
commit 673f0ce718
12 changed files with 328 additions and 45 deletions

View File

@@ -21,8 +21,8 @@ final class SceneModel: ObservableObject {
@Published var extractorButtonState: ArticleExtractorButtonState?
@Published var openInBrowserButtonState: Bool?
@Published var shareButtonState: Bool?
@Published var accountErrorMessage = ""
@Published var accountSyncErrors: [AccountSyncError] = []
var selectedArticles: [Article] {
timelineModel.selectedArticles
@@ -48,6 +48,7 @@ final class SceneModel: ObservableObject {
self.articleIconSchemeHandler = ArticleIconSchemeHandler(sceneModel: self)
self.webViewProvider = WebViewProvider(articleIconSchemeHandler: self.articleIconSchemeHandler!)
subscribeToAccountSyncErrors()
subscribeToToolbarChangeEvents()
}
@@ -146,6 +147,16 @@ private extension SceneModel {
}.store(in: &cancellables)
}
func subscribeToAccountSyncErrors() {
NotificationCenter.default.publisher(for: .AccountsDidFailToSyncWithErrors)
.sink { [weak self] notification in
guard let errors = notification.object as? [AccountSyncError] else {
return
}
self?.accountSyncErrors = errors
}.store(in: &cancellables)
}
// MARK: Button State Updates
func updateNextUnreadButtonState(accountManager: AccountManager) {