From b6d05e41f0e24f344ba429a67119e3ed49c5de0c Mon Sep 17 00:00:00 2001 From: Zaid Kokaja Date: Fri, 3 Jul 2020 10:44:55 -0400 Subject: [PATCH] Switch installed/stable version in outdated --- Brewlet/AppDelegate.swift | 2 +- Brewlet/Package.swift | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Brewlet/AppDelegate.swift b/Brewlet/AppDelegate.swift index 7875b01..2c1ad51 100644 --- a/Brewlet/AppDelegate.swift +++ b/Brewlet/AppDelegate.swift @@ -291,7 +291,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, PreferencesDelegate { */ func fillPackageMenu(packageMenu : NSMenu, packages: [Package]) { for package in packages { - let newVersion = package.versions.stable + let newVersion = package.getStableVersion() let currentVersion = package.getInstalledVersion() ?? "?" let title = "\(package.name) (\(currentVersion)) < \(newVersion)" diff --git a/Brewlet/Package.swift b/Brewlet/Package.swift index da94f8c..c02de3b 100644 --- a/Brewlet/Package.swift +++ b/Brewlet/Package.swift @@ -33,10 +33,14 @@ struct Package { var version: String? = nil if !installed.isEmpty { version = installed[0].version - - if revision > 0 { - version! += "_\(self.revision)" - } + } + return version + } + + func getStableVersion() -> String { + var version = self.versions.stable + if revision > 0 { + version += "_\(self.revision)" } return version }