From 48701b9169e260cc690b161d7f8ab6485802b8d9 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 12 Dec 2018 09:20:05 +0100 Subject: [PATCH 1/5] switch from the now deprecated to the new statuspage the "old" status page https://status.github.com is no deprecated and GitHub switched to a statuspage.io implementation with https://githubstatus.com. The page mentions the deprecation. This PR switches the url to the new status page and changes the status API model for the new REST-response. The new API replaced the `good` state with the state `none`. And has more fields, that are probably not relevant for the App. --- Classes/Settings/SettingsViewController.swift | 15 +++++++++------ .../GitHubAPI/GitHubAPIStatusRequest.swift | 15 +++++++++++---- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Classes/Settings/SettingsViewController.swift b/Classes/Settings/SettingsViewController.swift index 6b1aecafa..79ccbdeb3 100644 --- a/Classes/Settings/SettingsViewController.swift +++ b/Classes/Settings/SettingsViewController.swift @@ -84,15 +84,18 @@ GitHubSessionListener { case .success(let response): let text: String let color: UIColor - switch response.data.status { - case .good: - text = NSLocalizedString("Good", comment: "") + switch response.data.status.indicator { + case .none: + text = response.data.status.description color = Styles.Colors.Green.medium.color case .minor: - text = NSLocalizedString("Minor", comment: "") + text = response.data.status.description color = Styles.Colors.Yellow.medium.color case .major: - text = NSLocalizedString("Major", comment: "") + text = response.data.status.description + color = Styles.Colors.Red.medium.color + case .critical: + text = response.data.status.description color = Styles.Colors.Red.medium.color } strongSelf.apiStatusView.isHidden = false @@ -144,7 +147,7 @@ GitHubSessionListener { } private func onGitHubStatus() { - guard let url = URLBuilder(host: "status.github.com").add(path: "messages").url + guard let url = URLBuilder(host: "githubstatus.com").url else { return } presentSafari(url: url) } diff --git a/Local Pods/GitHubAPI/GitHubAPI/GitHubAPIStatusRequest.swift b/Local Pods/GitHubAPI/GitHubAPI/GitHubAPIStatusRequest.swift index 728b2366e..39a6ed73d 100644 --- a/Local Pods/GitHubAPI/GitHubAPI/GitHubAPIStatusRequest.swift +++ b/Local Pods/GitHubAPI/GitHubAPI/GitHubAPIStatusRequest.swift @@ -9,15 +9,22 @@ import Foundation public struct APIStatus: Codable { - public enum StatusType: String, Codable { - case good, minor, major + public let status: Status +} + +public struct Status: Codable { + public let indicator: StatusType + public let description: String + + public enum StatusType: String,Codable, CodingKey { + case none, minor, major, critical } - public let status: StatusType } + public struct GitHubAPIStatusRequest: HTTPRequest { public typealias ResponseType = V3DataResponse - public var url: String { return "https://status.github.com/api/status.json" } + public var url: String { return "https://www.githubstatus.com/api/v2/status.json" } public var logoutOnAuthFailure: Bool { return false } public var method: HTTPMethod { return .get } public var parameters: [String : Any]? { return nil } From 187f64e22fc375e0393db4623db13bb71d23b75c Mon Sep 17 00:00:00 2001 From: Bas Broek Date: Sat, 9 Mar 2019 13:06:22 +0100 Subject: [PATCH 2/5] Only set the status' text once --- Classes/Settings/SettingsViewController.swift | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/Classes/Settings/SettingsViewController.swift b/Classes/Settings/SettingsViewController.swift index 79ccbdeb3..d585fe895 100644 --- a/Classes/Settings/SettingsViewController.swift +++ b/Classes/Settings/SettingsViewController.swift @@ -82,21 +82,13 @@ GitHubSessionListener { strongSelf.apiStatusView.isHidden = true strongSelf.apiStatusLabel.text = NSLocalizedString("error", comment: "") case .success(let response): - let text: String + let text = response.data.status.description let color: UIColor switch response.data.status.indicator { - case .none: - text = response.data.status.description - color = Styles.Colors.Green.medium.color - case .minor: - text = response.data.status.description - color = Styles.Colors.Yellow.medium.color - case .major: - text = response.data.status.description - color = Styles.Colors.Red.medium.color - case .critical: - text = response.data.status.description - color = Styles.Colors.Red.medium.color + case .none: color = Styles.Colors.Green.medium.color + case .minor: color = Styles.Colors.Yellow.medium.color + case .major: color = Styles.Colors.Red.medium.color + case .critical: color = Styles.Colors.Red.medium.color } strongSelf.apiStatusView.isHidden = false strongSelf.apiStatusView.backgroundColor = color From 99a65d18effadea3754269748972c246344ea086 Mon Sep 17 00:00:00 2001 From: Bas Broek Date: Sat, 9 Mar 2019 13:06:47 +0100 Subject: [PATCH 3/5] Introduce a dark red for the critical API status --- Classes/Settings/SettingsViewController.swift | 2 +- Classes/Views/Styles.swift | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Classes/Settings/SettingsViewController.swift b/Classes/Settings/SettingsViewController.swift index d585fe895..894b753d2 100644 --- a/Classes/Settings/SettingsViewController.swift +++ b/Classes/Settings/SettingsViewController.swift @@ -88,7 +88,7 @@ GitHubSessionListener { case .none: color = Styles.Colors.Green.medium.color case .minor: color = Styles.Colors.Yellow.medium.color case .major: color = Styles.Colors.Red.medium.color - case .critical: color = Styles.Colors.Red.medium.color + case .critical: color = Styles.Colors.Red.dark.color } strongSelf.apiStatusView.isHidden = false strongSelf.apiStatusView.backgroundColor = color diff --git a/Classes/Views/Styles.swift b/Classes/Views/Styles.swift index 83a8d68f2..9674fce28 100644 --- a/Classes/Views/Styles.swift +++ b/Classes/Views/Styles.swift @@ -90,6 +90,7 @@ enum Styles { static let splitViewBackground = UIColor(red: 0.556863, green: 0.556863, blue: 0.576471, alpha: 1) enum Red { + static let dark = "75151d" static let medium = "cb2431" static let light = "ffeef0" } From 910bb2f7b3f8624bd918885b376606b3f20994c9 Mon Sep 17 00:00:00 2001 From: Bas Broek Date: Sat, 9 Mar 2019 13:06:53 +0100 Subject: [PATCH 4/5] Add a space --- Local Pods/GitHubAPI/GitHubAPI/GitHubAPIStatusRequest.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Local Pods/GitHubAPI/GitHubAPI/GitHubAPIStatusRequest.swift b/Local Pods/GitHubAPI/GitHubAPI/GitHubAPIStatusRequest.swift index 39a6ed73d..f101e8159 100644 --- a/Local Pods/GitHubAPI/GitHubAPI/GitHubAPIStatusRequest.swift +++ b/Local Pods/GitHubAPI/GitHubAPI/GitHubAPIStatusRequest.swift @@ -16,7 +16,7 @@ public struct Status: Codable { public let indicator: StatusType public let description: String - public enum StatusType: String,Codable, CodingKey { + public enum StatusType: String, Codable, CodingKey { case none, minor, major, critical } } From 87c9e54976ad54bc5935d7bc36f51fa2a18a5524 Mon Sep 17 00:00:00 2001 From: Bas Broek Date: Sat, 9 Mar 2019 13:08:48 +0100 Subject: [PATCH 5/5] Add "www."-prefix to prevent redirects --- Classes/Settings/SettingsViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Settings/SettingsViewController.swift b/Classes/Settings/SettingsViewController.swift index 894b753d2..e61a01815 100644 --- a/Classes/Settings/SettingsViewController.swift +++ b/Classes/Settings/SettingsViewController.swift @@ -139,7 +139,7 @@ GitHubSessionListener { } private func onGitHubStatus() { - guard let url = URLBuilder(host: "githubstatus.com").url + guard let url = URLBuilder(host: "www.githubstatus.com").url else { return } presentSafari(url: url) }