mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-06-21 22:09:09 -04:00
Updater fixes [release]
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user