diff --git a/src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java b/src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java index 2c2cf5425..e5597db08 100644 --- a/src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java +++ b/src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java @@ -50,6 +50,7 @@ public class UpdatesPreferencesController implements FxController { private final BooleanProperty upToDateLabelVisible = new SimpleBooleanProperty(false); private final ObjectProperty updateCheckState; private final DateTimeFormatter formatter; + private final BooleanBinding isUpdateSuccessfulAndCurrent; /* FXML */ public CheckBox checkForUpdatesCheckbox; @@ -71,15 +72,14 @@ public class UpdatesPreferencesController implements FxController { this.updateAvailable = updateChecker.updateAvailableProperty(); this.updateCheckState = updateChecker.updateCheckStateProperty(); this.formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(Locale.getDefault()); + this.isUpdateSuccessfulAndCurrent = updateCheckState.isEqualTo(UpdateChecker.UpdateCheckState.CHECK_SUCCESSFUL).and(latestVersion.isEqualTo(currentVersion)); } public void initialize() { checkForUpdatesCheckbox.selectedProperty().bindBidirectional(settings.checkForUpdates); - BooleanBinding isUpdateSuccessfulAndCurrent = updateCheckState.isEqualTo(UpdateChecker.UpdateCheckState.CHECK_SUCCESSFUL).and(latestVersion.isEqualTo(currentVersion)); - - updateCheckState.addListener((_, _, _) -> { - if (isUpdateSuccessfulAndCurrent.get()) { + isUpdateSuccessfulAndCurrent.addListener((_, _, newVal) -> { + if (newVal) { upToDateLabelVisible.set(true); PauseTransition delay = new PauseTransition(javafx.util.Duration.seconds(5)); delay.setOnFinished(_ -> upToDateLabelVisible.set(false));