Skip to content

Commit 2edced4

Browse files
committed
Further improvements to GUI Update Button logic
1 parent 94190a9 commit 2edced4

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### Improvements
44
* Show info in footer when a new version of the GUI is available #992
5+
* Further improvements to GUI Update Button logic
56
* Add GUI-wide settings class to keep certain settings across sessions and app starts #997
67
* Remove 30 second window option from Focus widget
78

OpenBCI_GUI/OpenBCI_GUI.pde

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ String localGUIVersionString = "v5.0.7";
6464
String localGUIVersionDate = "September 2021";
6565
String guiLatestVersionGithubAPI = "https://api.github.com/repos/OpenBCI/OpenBCI_GUI/releases/latest";
6666
String guiLatestReleaseLocation = "https://github.com/OpenBCI/OpenBCI_GUI/releases/latest";
67+
Boolean guiIsUpToDate;
6768

6869
PApplet ourApplet;
6970

OpenBCI_GUI/TopNav.pde

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -533,15 +533,20 @@ class TopNav {
533533
updateGuiVersionButton = createTNButton("updateGuiVersionButton", text, _x, _y, _w, _h, font, _fontSize, _bg, _textColor);
534534
//Attempt to compare local and remote GUI versions when TopNav is instantiated
535535
//This will also set the description/help-text for this cp5 button
536-
final Boolean upToDate = guiVersionIsUpToDate();
536+
//Do this check on app start and store as a global variable
537+
guiIsUpToDate = guiVersionIsUpToDate();
537538

538539
updateGuiVersionButton.onRelease(new CallbackListener() {
539540
public void controlEvent(CallbackEvent theEvent) {
540-
if (upToDate == null) {
541+
//Perform check again when button is pressed. User may have connected to internet by now!
542+
guiIsUpToDate = guiVersionIsUpToDate();
543+
544+
if (guiIsUpToDate == null) {
545+
outputError("Update GUI: Unable to check for new version of GUI. Try again when connected to the internet.");
541546
return;
542547
}
543548

544-
if (!upToDate) {
549+
if (!guiIsUpToDate) {
545550
openURLInBrowser(guiLatestReleaseLocation);
546551
outputInfo("Update GUI: Opening latest GUI release page using default browser");
547552
} else {
@@ -550,11 +555,11 @@ class TopNav {
550555
}
551556
});
552557

553-
if (upToDate == null) {
558+
if (guiIsUpToDate == null) {
554559
return;
555560
}
556561

557-
if (!upToDate) {
562+
if (!guiIsUpToDate) {
558563
outputWarn("Update Available! Press the \"Update\" button at the top of the GUI to download the latest version.");
559564
}
560565
}

0 commit comments

Comments
 (0)