From 3753ca92cd9fc43cbff259d9fb5c112ba4b8b7a0 Mon Sep 17 00:00:00 2001 From: Serhiy Mytrovtsiy Date: Mon, 6 Jun 2022 21:30:22 +0200 Subject: [PATCH] fix: allow to check the newest version via button even if the last check was recently --- Kit/plugins/Updater.swift | 4 ++-- Stats/Views/AppSettings.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Kit/plugins/Updater.swift b/Kit/plugins/Updater.swift index 658b6661..88179db8 100644 --- a/Kit/plugins/Updater.swift +++ b/Kit/plugins/Updater.swift @@ -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 } diff --git a/Stats/Views/AppSettings.swift b/Stats/Views/AppSettings.swift index 640daf4e..1abb32d2 100644 --- a/Stats/Views/AppSettings.swift +++ b/Stats/Views/AppSettings.swift @@ -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) {