diff --git a/pullBar.xcodeproj/project.pbxproj b/pullBar.xcodeproj/project.pbxproj index c4f861f..5c1d738 100644 --- a/pullBar.xcodeproj/project.pbxproj +++ b/pullBar.xcodeproj/project.pbxproj @@ -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 */; }; @@ -31,7 +30,6 @@ 769F4E7A277B97B300594911 /* Notifications.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notifications.swift; sourceTree = ""; }; 769F4E7C277CAFAD00594911 /* StringExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringExtensions.swift; sourceTree = ""; }; 76F7DACF28A88CAB0086A3B0 /* TokenStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TokenStatus.swift; sourceTree = ""; }; - 76F7DAD128A9CA1F0086A3B0 /* AppStoreDtos.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppStoreDtos.swift; sourceTree = ""; }; 8C55444A274AD7B20079CA42 /* DateExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateExtensions.swift; sourceTree = ""; }; 8C55444C274AD9E00079CA42 /* NSImageExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSImageExtensions.swift; sourceTree = ""; }; 8CECBBDF2742AAF800A2802D /* pullBar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = pullBar.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -96,7 +94,6 @@ 8CECBBF22742AB3F00A2802D /* GitHubClient.swift */, 8CECBBF32742AB3F00A2802D /* GitHubDtos.swift */, 76F7DACF28A88CAB0086A3B0 /* TokenStatus.swift */, - 76F7DAD128A9CA1F0086A3B0 /* AppStoreDtos.swift */, ); path = GitHub; sourceTree = ""; @@ -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 */, diff --git a/pullBar/AppDelegate.swift b/pullBar/AppDelegate.swift index 2c3ec84..9f43499 100644 --- a/pullBar/AppDelegate.swift +++ b/pullBar/AppDelegate.swift @@ -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: "") } @@ -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) - } - } } diff --git a/pullBar/GitHub/AppStoreDtos.swift b/pullBar/GitHub/AppStoreDtos.swift deleted file mode 100644 index 342530d..0000000 --- a/pullBar/GitHub/AppStoreDtos.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// AppstoreDtos.swift -// pullBar -// -// Created by Pavel Makhov on 2022-08-14. -// - -import Foundation - -struct Releases: Codable { - - var results: [Release] - - enum CodingKeys: String, CodingKey { - case results - } -} - -struct Release: Codable { - - var version: String - var trackViewUrl: URL - - enum CodingKeys: String, CodingKey { - case version - case trackViewUrl - } -} diff --git a/pullBar/GitHub/GitHubClient.swift b/pullBar/GitHub/GitHubClient.swift index 9df6f8d..5b6d5a4 100644 --- a/pullBar/GitHub/GitHubClient.swift +++ b/pullBar/GitHub/GitHubClient.swift @@ -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),