Coalesce refresh progress updates
This commit is contained in:
parent
46762bf297
commit
92f6ee3f42
|
@ -6,10 +6,10 @@
|
||||||
// Copyright © 2020 Ranchero Software. All rights reserved.
|
// Copyright © 2020 Ranchero Software. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Account
|
|
||||||
import Combine
|
|
||||||
import Foundation
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import Combine
|
||||||
|
import RSCore
|
||||||
|
import Account
|
||||||
|
|
||||||
class RefreshProgressModel: ObservableObject {
|
class RefreshProgressModel: ObservableObject {
|
||||||
|
|
||||||
|
@ -40,11 +40,15 @@ class RefreshProgressModel: ObservableObject {
|
||||||
// MARK: Observing account changes
|
// MARK: Observing account changes
|
||||||
|
|
||||||
private func observeRefreshProgress() {
|
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
|
// MARK: Refreshing state
|
||||||
|
|
||||||
|
@objc private func accountRefreshProgressDidChange() {
|
||||||
|
CoalescingQueue.standard.add(self, #selector(updateState))
|
||||||
|
}
|
||||||
|
|
||||||
@objc private func updateState() {
|
@objc private func updateState() {
|
||||||
let progress = AccountManager.shared.combinedRefreshProgress
|
let progress = AccountManager.shared.combinedRefreshProgress
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue