From d836bfcce6be0168b16faa26f3e8ddcb18185215 Mon Sep 17 00:00:00 2001 From: crschnick Date: Tue, 4 Apr 2023 18:58:28 +0000 Subject: [PATCH] Updater fixes [release] --- app/src/main/java/io/xpipe/app/core/App.java | 24 ++++++++++++++++--- .../java/io/xpipe/app/core/AppMainWindow.java | 6 +++-- .../java/io/xpipe/app/update/AppUpdater.java | 4 ++++ dist/changelogs/0.5.32.md | 3 ++- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/core/App.java b/app/src/main/java/io/xpipe/app/core/App.java index bc463aeb0..014c57c60 100644 --- a/app/src/main/java/io/xpipe/app/core/App.java +++ b/app/src/main/java/io/xpipe/app/core/App.java @@ -5,9 +5,11 @@ import io.xpipe.app.comp.AppLayoutComp; import io.xpipe.app.fxcomps.util.PlatformThread; import io.xpipe.app.issue.ErrorEvent; import io.xpipe.app.issue.TrackEvent; +import io.xpipe.app.update.AppUpdater; import io.xpipe.core.process.OsType; import javafx.application.Application; import javafx.application.Platform; +import javafx.beans.binding.Bindings; import javafx.scene.image.Image; import javafx.scene.input.MouseEvent; import javafx.stage.Stage; @@ -69,11 +71,27 @@ public class App extends Application { // AppActionLinkDetector.detectOnFocus(); }); }); - var title = - String.format("X-Pipe Desktop (Alpha %s)", AppProperties.get().getVersion()); + + var titleBinding = Bindings.createStringBinding( + () -> { + var base = String.format( + "X-Pipe Desktop (%s)", AppProperties.get().getVersion()); + var suffix = AppUpdater.get().getLastUpdateCheckResult().getValue() != null + ? String.format( + " (Update to %s available)", + AppUpdater.get() + .getLastUpdateCheckResult() + .getValue() + .getVersion()) + : ""; + return base + suffix; + }, + AppUpdater.get().getLastUpdateCheckResult()); + var appWindow = new AppMainWindow(stage); + appWindow.getStage().titleProperty().bind(PlatformThread.sync(titleBinding)); appWindow.initialize(); - appWindow.setContent(title, content); + appWindow.setContent(content); TrackEvent.info("Application window initialized"); stage.setOnShown(event -> { focus(); diff --git a/app/src/main/java/io/xpipe/app/core/AppMainWindow.java b/app/src/main/java/io/xpipe/app/core/AppMainWindow.java index 172ac6c74..b2064a4c6 100644 --- a/app/src/main/java/io/xpipe/app/core/AppMainWindow.java +++ b/app/src/main/java/io/xpipe/app/core/AppMainWindow.java @@ -16,6 +16,7 @@ import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.stage.Screen; import javafx.stage.Stage; +import lombok.Getter; import java.time.Duration; import java.time.Instant; @@ -24,6 +25,8 @@ import java.time.temporal.ChronoUnit; public class AppMainWindow { private static AppMainWindow INSTANCE; + + @Getter private final Stage stage; private final BooleanProperty windowActive = new SimpleBooleanProperty(false); private Thread thread; @@ -240,8 +243,7 @@ public class AppMainWindow { TrackEvent.debug("Set content reload listener"); } - public void setContent(String title, Comp content) { - stage.setTitle(title); + public void setContent(Comp content) { setupContent(content); AppWindowHelper.setupStylesheets(stage.getScene()); } diff --git a/app/src/main/java/io/xpipe/app/update/AppUpdater.java b/app/src/main/java/io/xpipe/app/update/AppUpdater.java index bcc067148..5514077e6 100644 --- a/app/src/main/java/io/xpipe/app/update/AppUpdater.java +++ b/app/src/main/java/io/xpipe/app/update/AppUpdater.java @@ -78,6 +78,10 @@ public class AppUpdater { AppCache.update("downloadedUpdate", n); }); lastUpdateCheckResult.addListener((c, o, n) -> { + if (n != null && downloadedUpdate.getValue() != null && n.getVersion().equals(downloadedUpdate.getValue().getVersion())) { + return; + } + downloadedUpdate.setValue(null); }); diff --git a/dist/changelogs/0.5.32.md b/dist/changelogs/0.5.32.md index 4a1060db3..c5d863045 100644 --- a/dist/changelogs/0.5.32.md +++ b/dist/changelogs/0.5.32.md @@ -1,6 +1,7 @@ +- Add file type icons to file browser +- Add shift-select ability to select range of files to file browser - Fix various file browser bugs - Improve memory footprint - Properly update last used time for connections - Show changelog when prompting for an update installation - Improve icon semantics in connection overview -- \ No newline at end of file