Skip to content

Commit

Permalink
Prompt the user if the app is up to date
Browse files Browse the repository at this point in the history
When the user manually requests to check for updates, the app will now prompt the user even if the app is up to date.
  • Loading branch information
frannyfx committed Nov 5, 2018
1 parent 5f0a8a2 commit 18ea658
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions kingsapp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.1</string>
<string>1.1.1</string>
<key>CFBundleVersion</key>
<string>35</string>
<string>3</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>LSUIElement</key>
Expand Down
13 changes: 9 additions & 4 deletions kingsapp/StatusMenuController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class StatusMenuController: NSObject, PreferencesWindowDelegate {
}

@IBAction func checkForUpdatesClicked(_ sender: Any) {
self.checkForUpdatesAndPrompt()
self.checkForUpdatesAndPrompt(promptIfUnavailable: true)
}

// Utils
Expand Down Expand Up @@ -66,7 +66,7 @@ class StatusMenuController: NSObject, PreferencesWindowDelegate {
}

// Check for updates
self.checkForUpdatesAndPrompt()
self.checkForUpdatesAndPrompt(promptIfUnavailable: false)

// Grab calendar from cache
currentCalendar = loadCachedCalendar()
Expand All @@ -89,12 +89,12 @@ class StatusMenuController: NSObject, PreferencesWindowDelegate {
}
}

func checkForUpdatesAndPrompt() {
func checkForUpdatesAndPrompt(promptIfUnavailable: Bool) {
self.utils.checkForUpdates() { (updateAvailable) -> () in
DispatchQueue.main.async { [unowned self] in
print("Update available:", updateAvailable)
let alert = NSAlert()
if updateAvailable {
let alert = NSAlert()
alert.informativeText = "There's an update available."
alert.messageText = "Update available."
alert.alertStyle = .warning
Expand All @@ -103,6 +103,11 @@ class StatusMenuController: NSObject, PreferencesWindowDelegate {
if alert.runModal() == NSApplication.ModalResponse.alertFirstButtonReturn {
NSWorkspace.shared.open(URL(string: "https://github.com/frannyfx/kingsapp/releases")!)
}
} else if (promptIfUnavailable) {
alert.informativeText = "KingsApp is up to date."
alert.messageText = "Up to date."
alert.alertStyle = .warning
alert.runModal()
}
}
}
Expand Down

0 comments on commit 18ea658

Please sign in to comment.