Skip to content

Commit

Permalink
Merge pull request #11 from menubar-apps/remove-check-for-updates
Browse files Browse the repository at this point in the history
Remove Check For Updates
  • Loading branch information
streetturtle authored Aug 15, 2022
2 parents 5146bd5 + e0384c9 commit 5748729
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 94 deletions.
4 changes: 0 additions & 4 deletions pullBar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
769F4E7B277B97B300594911 /* Notifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 769F4E7A277B97B300594911 /* Notifications.swift */; };
769F4E7D277CAFAD00594911 /* StringExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 769F4E7C277CAFAD00594911 /* StringExtensions.swift */; };
76F7DAD028A88CAB0086A3B0 /* TokenStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76F7DACF28A88CAB0086A3B0 /* TokenStatus.swift */; };
76F7DAD228A9CA1F0086A3B0 /* AppStoreDtos.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76F7DAD128A9CA1F0086A3B0 /* AppStoreDtos.swift */; };
8C55444B274AD7B20079CA42 /* DateExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C55444A274AD7B20079CA42 /* DateExtensions.swift */; };
8C55444D274AD9E00079CA42 /* NSImageExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C55444C274AD9E00079CA42 /* NSImageExtensions.swift */; };
8CECBBE32742AAF900A2802D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CECBBE22742AAF900A2802D /* AppDelegate.swift */; };
Expand All @@ -31,7 +30,6 @@
769F4E7A277B97B300594911 /* Notifications.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notifications.swift; sourceTree = "<group>"; };
769F4E7C277CAFAD00594911 /* StringExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringExtensions.swift; sourceTree = "<group>"; };
76F7DACF28A88CAB0086A3B0 /* TokenStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokenStatus.swift; sourceTree = "<group>"; };
76F7DAD128A9CA1F0086A3B0 /* AppStoreDtos.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppStoreDtos.swift; sourceTree = "<group>"; };
8C55444A274AD7B20079CA42 /* DateExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateExtensions.swift; sourceTree = "<group>"; };
8C55444C274AD9E00079CA42 /* NSImageExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSImageExtensions.swift; sourceTree = "<group>"; };
8CECBBDF2742AAF800A2802D /* pullBar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = pullBar.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -96,7 +94,6 @@
8CECBBF22742AB3F00A2802D /* GitHubClient.swift */,
8CECBBF32742AB3F00A2802D /* GitHubDtos.swift */,
76F7DACF28A88CAB0086A3B0 /* TokenStatus.swift */,
76F7DAD128A9CA1F0086A3B0 /* AppStoreDtos.swift */,
);
path = GitHub;
sourceTree = "<group>";
Expand Down Expand Up @@ -209,7 +206,6 @@
8CECBBF52742AB3F00A2802D /* GitHubDtos.swift in Sources */,
769F4E1B2765A2B900594911 /* AboutView.swift in Sources */,
8CECBC0927436C2200A2802D /* NSMutableAttributedStringExtensions.swift in Sources */,
76F7DAD228A9CA1F0086A3B0 /* AppStoreDtos.swift in Sources */,
8CECBBF42742AB3F00A2802D /* GitHubClient.swift in Sources */,
8C55444D274AD9E00079CA42 /* NSImageExtensions.swift in Sources */,
8CECBBFE2742AC0800A2802D /* DefaultsExtensions.swift in Sources */,
Expand Down
36 changes: 0 additions & 36 deletions pullBar/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ extension AppDelegate {
self.menu.addItem(.separator())
self.menu.addItem(withTitle: "Preferences...", action: #selector(self.openPrefecencesWindow), keyEquivalent: "")
self.menu.addItem(withTitle: "About PullBar", action: #selector(self.openAboutWindow), keyEquivalent: "")
self.menu.addItem(withTitle: "Check for Updates...", action: #selector(self.checkForUpdates), keyEquivalent: "")
self.menu.addItem(withTitle: "Quit", action: #selector(self.quit), keyEquivalent: "")
}

Expand Down Expand Up @@ -359,39 +358,4 @@ extension AppDelegate {
NSLog("User click Quit")
NSApplication.shared.terminate(self)
}

@objc
func checkForUpdates(_: NSStatusBarButton?) {
let currentVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
ghClient.getLatestRelease { latestRelease in
if let latestRelease = latestRelease {
let versionComparison = currentVersion.compare(latestRelease.version.replacingOccurrences(of: "v", with: ""), options: .numeric)
if versionComparison == .orderedAscending {
self.downloadNewVersionDialog(link: latestRelease.trackViewUrl)
} else {
self.dialogWithText(text: "You have the latest version installed!")
}
}
}
}

func dialogWithText(text: String) -> Void {
let alert = NSAlert()
alert.messageText = text
alert.alertStyle = .informational
alert.addButton(withTitle: "OK")
alert.runModal()
}

func downloadNewVersionDialog(link: URL) -> Void {
let alert = NSAlert()
alert.messageText = "New version is available!"
alert.alertStyle = .informational
alert.addButton(withTitle: "Download")
alert.addButton(withTitle: "Cancel")
let pressedButton = alert.runModal()
if (pressedButton == .alertFirstButtonReturn) {
NSWorkspace.shared.open(link)
}
}
}
28 changes: 0 additions & 28 deletions pullBar/GitHub/AppStoreDtos.swift

This file was deleted.

26 changes: 0 additions & 26 deletions pullBar/GitHub/GitHubClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,32 +183,6 @@ public class GitHubClient {
"""
}

func getLatestRelease(completion:@escaping (((Release?) -> Void))) -> Void {
let headers: HTTPHeaders = [
.contentType("application/json"),
.accept("application/json")
]
let bundleId = Bundle.main.infoDictionary!["CFBundleIdentifier"] as! String
AF.request("https://itunes.apple.com/lookup?bundleId=\(bundleId)",
method: .get,
encoding: JSONEncoding.default,
headers: headers)
.validate(statusCode: 200..<300)
.responseDecodable(of: Releases.self) { response in
switch response.result {
case .success(let latestRelease):
completion(latestRelease.results.first)
case .failure(let error):
completion(nil)
if let data = response.data {
let json = String(data: data, encoding: String.Encoding.utf8)
// print("Failure Response: \(json)")
}
sendNotification(body: error.localizedDescription)
}
}
}

func getUser(completion: @escaping (User?) -> Void) {
let headers: HTTPHeaders = [
.authorization(bearerToken: githubToken),
Expand Down

0 comments on commit 5748729

Please sign in to comment.