Coalesce refresh progress updates

This commit is contained in:
Maurice Parker 2020-07-15 21:32:56 -05:00
parent 46762bf297
commit 92f6ee3f42
1 changed files with 8 additions and 4 deletions

View File

@ -6,10 +6,10 @@
// Copyright © 2020 Ranchero Software. All rights reserved.
//
import Account
import Combine
import Foundation
import SwiftUI
import Combine
import RSCore
import Account
class RefreshProgressModel: ObservableObject {
@ -40,11 +40,15 @@ class RefreshProgressModel: ObservableObject {
// MARK: Observing account changes
private func observeRefreshProgress() {
NotificationCenter.default.addObserver(self, selector: #selector(updateState), name: .AccountRefreshProgressDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(accountRefreshProgressDidChange), name: .AccountRefreshProgressDidChange, object: nil)
}
// MARK: Refreshing state
@objc private func accountRefreshProgressDidChange() {
CoalescingQueue.standard.add(self, #selector(updateState))
}
@objc private func updateState() {
let progress = AccountManager.shared.combinedRefreshProgress