about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tracker_frame.cpp40
1 files changed, 15 insertions, 25 deletions
diff --git a/src/tracker_frame.cpp b/src/tracker_frame.cpp index 49f947f..a74e81e 100644 --- a/src/tracker_frame.cpp +++ b/src/tracker_frame.cpp
@@ -135,9 +135,7 @@ void TrackerFrame::OnStatusChanged(wxCommandEvent &event) {
135 135
136void TrackerFrame::CheckForUpdates(bool manual) { 136void TrackerFrame::CheckForUpdates(bool manual) {
137 wxWebRequest request = wxWebSession::GetDefault().CreateRequest( 137 wxWebRequest request = wxWebSession::GetDefault().CreateRequest(
138 this, 138 this, "https://code.fourisland.com/lingo-ap-tracker/plain/VERSION");
139 "https://api.github.com/repos/hatkirby/lingo-ap-tracker/"
140 "releases?per_page=8");
141 139
142 if (!request.IsOk()) { 140 if (!request.IsOk()) {
143 if (manual) { 141 if (manual) {
@@ -153,28 +151,20 @@ void TrackerFrame::CheckForUpdates(bool manual) {
153 Bind(wxEVT_WEBREQUEST_STATE, [this, manual](wxWebRequestEvent &evt) { 151 Bind(wxEVT_WEBREQUEST_STATE, [this, manual](wxWebRequestEvent &evt) {
154 if (evt.GetState() == wxWebRequest::State_Completed) { 152 if (evt.GetState() == wxWebRequest::State_Completed) {
155 std::string response = evt.GetResponse().AsString().ToStdString(); 153 std::string response = evt.GetResponse().AsString().ToStdString();
156 nlohmann::json parsed_response = nlohmann::json::parse(response); 154
157 155 Version latest_version(response);
158 if (parsed_response.is_array() && !parsed_response.empty()) { 156 if (kTrackerVersion < latest_version) {
159 // This will parse to 0.0.0 if it's invalid, which will always be older 157 std::ostringstream message_text;
160 // than our current version. 158 message_text << "There is a newer version of Lingo AP Tracker "
161 Version latest_version( 159 "available. You have "
162 parsed_response[0]["tag_name"].get<std::string>()); 160 << kTrackerVersion << ", and the latest version is "
163 if (kTrackerVersion < latest_version) { 161 << latest_version << ". Would you like to update?";
164 std::ostringstream message_text; 162
165 message_text << "There is a newer version of Lingo AP Tracker " 163 if (wxMessageBox(message_text.str(), "Update available", wxYES_NO) ==
166 "available. You have " 164 wxYES) {
167 << kTrackerVersion << ", and the latest version is " 165 wxLaunchDefaultBrowser(
168 << latest_version << ". Would you like to update?"; 166 "https://code.fourisland.com/lingo-ap-tracker/about/"
169 167 "CHANGELOG.md");
170 if (wxMessageBox(message_text.str(), "Update available", wxYES_NO) ==
171 wxYES) {
172 wxLaunchDefaultBrowser(
173 parsed_response[0]["html_url"].get<std::string>());
174 }
175 } else if (manual) {
176 wxMessageBox("Lingo AP Tracker is up to date!", "Lingo AP Tracker",
177 wxOK);
178 } 168 }
179 } else if (manual) { 169 } else if (manual) {
180 wxMessageBox("Lingo AP Tracker is up to date!", "Lingo AP Tracker", 170 wxMessageBox("Lingo AP Tracker is up to date!", "Lingo AP Tracker",