fix: allow to check the newest version via button even if the last check was recently

This commit is contained in:
Serhiy Mytrovtsiy
2022-06-06 21:30:22 +02:00
parent 5b79e8df30
commit 3753ca92cd
2 changed files with 4 additions and 4 deletions

View File

@@ -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
}

View File

@@ -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) {