Skip to content

Commit

Permalink
Fix crash upon first launch
Browse files Browse the repository at this point in the history
  • Loading branch information
frannyfx committed Feb 20, 2020
1 parent ac778f5 commit 09a0757
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion kingsapp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundleShortVersionString</key>
<string>1.1.3</string>
<key>CFBundleVersion</key>
<string>38</string>
<string>43</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>LSUIElement</key>
Expand Down
12 changes: 5 additions & 7 deletions kingsapp/StatusMenuController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,10 @@ class StatusMenuController: NSObject, PreferencesWindowDelegate {
}

func needsToCheckForUpdate() -> Bool {
// Don't load it from disk if it's cached
if self.lastUpdateCheck == nil {
self.lastUpdateCheck = dateFormatter.date(from: userDefaults.object(forKey: "lastUpdateCheck") as! String)
if lastUpdateCheck == nil {
return true
}
// Check when it was last updated
let lastUpdateString = userDefaults.object(forKey: "lastUpdateCheck")
if (lastUpdateString == nil) {
return true;
}

// Create threshold date
Expand All @@ -208,7 +206,7 @@ class StatusMenuController: NSObject, PreferencesWindowDelegate {
var components = DateComponents()
components.hour = -1 * hoursThreshold
let thresholdDate = NSCalendar.current.date(byAdding: components, to: currentDate)
return !(self.lastUpdateCheck! > thresholdDate!)
return dateFormatter.date(from: lastUpdateString as! String)! < thresholdDate!
}

func loadCredentials() {
Expand Down

0 comments on commit 09a0757

Please sign in to comment.