mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-15 00:34:08 +09:00
fix: allow to check the newest version via button even if the last check was recently
This commit is contained in:
@@ -69,9 +69,9 @@ public class Updater {
|
||||
observation?.invalidate()
|
||||
}
|
||||
|
||||
public func check(completion: @escaping (_ result: version_s?, _ error: Error?) -> Void) {
|
||||
public func check(force: Bool = false, completion: @escaping (_ result: version_s?, _ error: Error?) -> Void) {
|
||||
let diff = (Int(Date().timeIntervalSince1970) - self.lastCheckTS) / 60
|
||||
if diff <= 10 {
|
||||
if !force && diff <= 10 {
|
||||
completion(nil, "last check was \(diff) minutes ago, stopping...")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ class ApplicationSettings: NSStackView {
|
||||
// MARK: - actions
|
||||
|
||||
@objc func updateAction(_ sender: NSObject) {
|
||||
updater.check { result, error in
|
||||
updater.check(force: true, completion: { result, error in
|
||||
if error != nil {
|
||||
debug("error updater.check(): \(error!.localizedDescription)")
|
||||
return
|
||||
@@ -218,7 +218,7 @@ class ApplicationSettings: NSStackView {
|
||||
self.updateWindow.open(version)
|
||||
return
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@objc private func toggleUpdateInterval(_ sender: NSMenuItem) {
|
||||
|
||||
Reference in New Issue
Block a user