diff --git a/Delta/Game Selection/GamesViewController.swift b/Delta/Game Selection/GamesViewController.swift index 0935dc8..822ddf2 100644 --- a/Delta/Game Selection/GamesViewController.swift +++ b/Delta/Game Selection/GamesViewController.swift @@ -48,7 +48,15 @@ class GamesViewController: UIViewController private var searchController: RSTSearchController? - private var syncingToastView: RSTToastView? + private var syncingToastView: RSTToastView? { + didSet { + if self.syncingToastView == nil + { + self.syncingProgressObservation = nil + } + } + } + private var syncingProgressObservation: NSKeyValueObservation? override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { fatalError("initWithNibName: not implemented") @@ -382,13 +390,21 @@ private extension GamesViewController func showSyncingToastViewIfNeeded() { - guard let coordinator = SyncManager.shared.coordinator, coordinator.isSyncing && self.syncingToastView == nil else { return } - - let toastView = RSTToastView(text: NSLocalizedString("Syncing...", comment: ""), detailText: nil) + guard let coordinator = SyncManager.shared.coordinator, let syncProgress = SyncManager.shared.syncProgress, coordinator.isSyncing && self.syncingToastView == nil else { return } + + let toastView = RSTToastView(text: NSLocalizedString("Syncing...", comment: ""), detailText: syncProgress.localizedAdditionalDescription) toastView.activityIndicatorView.startAnimating() toastView.addTarget(self, action: #selector(GamesViewController.hideSyncingToastView), for: .touchUpInside) toastView.show(in: self.view) + self.syncingProgressObservation = syncProgress.observe(\.localizedAdditionalDescription) { [weak toastView, weak self] (progress, change) in + DispatchQueue.main.async { + // Prevent us from updating text right as we're dismissing the toast view. + guard self?.syncingToastView != nil else { return } + toastView?.detailTextLabel.text = progress.localizedAdditionalDescription + } + } + self.syncingToastView = toastView } @@ -402,6 +418,7 @@ private extension GamesViewController case .failure(let error): toastView = RSTToastView(text: NSLocalizedString("Sync Failed", comment: ""), detailText: error.failureReason) } + toastView.textLabel.textAlignment = .center toastView.addTarget(self, action: #selector(GamesViewController.presentSyncResultsViewController), for: .touchUpInside) toastView.show(in: self.view, duration: 2.0) diff --git a/Delta/Syncing/SyncManager.swift b/Delta/Syncing/SyncManager.swift index 1c2525b..79e8b31 100644 --- a/Delta/Syncing/SyncManager.swift +++ b/Delta/Syncing/SyncManager.swift @@ -92,6 +92,8 @@ final class SyncManager return self.coordinator?.recordController } + private(set) var syncProgress: Progress? + private(set) var previousSyncResult: SyncResult? private(set) var coordinator: SyncCoordinator? @@ -187,7 +189,8 @@ extension SyncManager func sync() { - self.coordinator?.sync() + let progress = self.coordinator?.sync() + self.syncProgress = progress } } @@ -198,6 +201,8 @@ private extension SyncManager guard let result = notification.userInfo?[SyncCoordinator.syncResultKey] as? SyncResult else { return } self.previousSyncResult = result + self.syncProgress = nil + print("Finished syncing!") } diff --git a/External/Harmony b/External/Harmony index 39311d3..0301f3e 160000 --- a/External/Harmony +++ b/External/Harmony @@ -1 +1 @@ -Subproject commit 39311d36660c98bc6f240d7134c39f8361fc7b3e +Subproject commit 0301f3ea5d3ede4f8eb3c06227a4f63b9b7b247c diff --git a/External/Roxas b/External/Roxas index ffd65b8..8ab1eec 160000 --- a/External/Roxas +++ b/External/Roxas @@ -1 +1 @@ -Subproject commit ffd65b85417db90895361446ea848d68a8ef9e4c +Subproject commit 8ab1eecff273609896dff9bb18f17185ffa08f26