Reorder arguments to PostponingBlock.init.
This commit is contained in:
parent
57399838dc
commit
a91fd53100
|
@ -32,7 +32,7 @@ public protocol DataFileDelegate: AnyObject {
|
|||
private let fileURL: URL
|
||||
|
||||
private lazy var postponingBlock: PostponingBlock = {
|
||||
PostponingBlock(delayInterval: 1.0, name: "DataFile \(fileURL.absoluteString)") { [weak self] in
|
||||
PostponingBlock(name: "DataFile \(fileURL.absoluteString)", delayInterval: 1.0) { [weak self] in
|
||||
self?.saveToDiskIfNeeded()
|
||||
}
|
||||
}()
|
||||
|
|
|
@ -11,6 +11,8 @@ import os
|
|||
/// Runs a block of code in the future. Each time `runInFuture` is called, the block is postponed again until the future by `delayInterval`.
|
||||
@MainActor public final class PostponingBlock {
|
||||
|
||||
public static let delayIntervalForUI: TimeInterval = 0.05
|
||||
|
||||
private let block: @MainActor () -> Void
|
||||
private let delayInterval: TimeInterval
|
||||
private let name: String // For debugging
|
||||
|
@ -18,7 +20,7 @@ import os
|
|||
|
||||
private let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "PostponingBlock")
|
||||
|
||||
public init(delayInterval: TimeInterval, name: String, block: @MainActor @escaping () -> Void) {
|
||||
public init(name: String, delayInterval: TimeInterval = PostponingBlock.delayIntervalForUI, block: @MainActor @escaping () -> Void) {
|
||||
|
||||
self.delayInterval = delayInterval
|
||||
self.name = name
|
||||
|
|
|
@ -71,7 +71,7 @@ import Sparkle
|
|||
@IBOutlet var checkForUpdatesMenuItem: NSMenuItem!
|
||||
|
||||
private lazy var postponingUpdateDockBadgeBlock: PostponingBlock = {
|
||||
PostponingBlock(delayInterval: 0.05, name: "Update Dock Badge", block: updateDockBadge)
|
||||
PostponingBlock(name: "Update Dock Badge", delayInterval: 0.05, block: updateDockBadge)
|
||||
}()
|
||||
|
||||
var unreadCount = 0 {
|
||||
|
|
|
@ -60,6 +60,10 @@ final class MainWindowController : NSWindowController, NSUserInterfaceValidation
|
|||
private var searchSmartFeed: SmartFeed? = nil
|
||||
private var restoreArticleWindowScrollY: CGFloat?
|
||||
|
||||
private lazy var postponingMakeToolbarValidateBlock: PostponingBlock = {
|
||||
PostponingBlock(name: "Make Toolbar Validate", delayInterval: 0.05, block: makeToolbarValidate)
|
||||
}()
|
||||
|
||||
// MARK: - NSWindowController
|
||||
|
||||
override func windowDidLoad() {
|
||||
|
@ -147,7 +151,7 @@ final class MainWindowController : NSWindowController, NSUserInterfaceValidation
|
|||
// MARK: - Notifications
|
||||
|
||||
@objc func refreshProgressDidChange(_ note: Notification) {
|
||||
CoalescingQueue.standard.add(self, #selector(makeToolbarValidate))
|
||||
queueMakeToolbarValidate()
|
||||
}
|
||||
|
||||
@objc func unreadCountDidChange(_ note: Notification) {
|
||||
|
@ -195,7 +199,12 @@ final class MainWindowController : NSWindowController, NSUserInterfaceValidation
|
|||
|
||||
// MARK: - Toolbar
|
||||
|
||||
@objc func makeToolbarValidate() {
|
||||
func queueMakeToolbarValidate() {
|
||||
|
||||
postponingMakeToolbarValidateBlock.runInFuture()
|
||||
}
|
||||
|
||||
func makeToolbarValidate() {
|
||||
|
||||
window?.toolbar?.validateVisibleItems()
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ import Images
|
|||
#endif
|
||||
|
||||
private lazy var postponingBlock: PostponingBlock = {
|
||||
PostponingBlock(delayInterval: 1.0, name: "SmartFeed") {
|
||||
PostponingBlock(name: "SmartFeed", delayInterval: 1.0) {
|
||||
Task {
|
||||
try? await self.fetchUnreadCounts()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue