moved logic of update checking from FxApplication class to UpdateReminderComponent

This commit is contained in:
Jan-Peter Klein
2023-07-20 11:06:55 +02:00
parent 96253f636a
commit 0a07103a4f
3 changed files with 14 additions and 11 deletions

View File

@@ -9,7 +9,6 @@ import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.inject.Named;
import javafx.application.Platform;
import java.time.LocalDate;
import java.util.concurrent.TimeUnit;
@FxApplicationScoped
@@ -69,9 +68,7 @@ public class FxApplication {
return null;
});
if (LocalDate.parse(settings.lastUpdateCheck.get()).isBefore(LocalDate.now().minusDays(14)) && !settings.checkForUpdates.getValue()) {
appWindows.showUpdateReminderWindow();
}
appWindows.checkAndShowUpdateReminderWindow();
launchEventHandler.startHandlingLaunchEvents();
autoUnlocker.tryUnlockForTimespan(2, TimeUnit.MINUTES);

View File

@@ -130,8 +130,8 @@ public class FxApplicationWindows {
CompletableFuture.runAsync(() -> quitWindowBuilder.build().showQuitWindow(response,forced), Platform::runLater);
}
public void showUpdateReminderWindow() {
CompletableFuture.runAsync(() -> updateReminderWindowBuilder.create().showUpdateReminderWindow(), Platform::runLater);
public void checkAndShowUpdateReminderWindow() {
CompletableFuture.runAsync(() -> updateReminderWindowBuilder.create().checkAndShowUpdateReminderWindow(), Platform::runLater);
}
public CompletionStage<Void> startUnlockWorkflow(Vault vault, @Nullable Stage owner) {

View File

@@ -2,11 +2,13 @@ package org.cryptomator.ui.updatereminder;
import dagger.Lazy;
import dagger.Subcomponent;
import org.cryptomator.common.settings.Settings;
import org.cryptomator.ui.common.FxmlFile;
import org.cryptomator.ui.common.FxmlScene;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.time.LocalDate;
@UpdateReminderScoped
@Subcomponent(modules = {UpdateReminderModule.class})
@@ -18,11 +20,15 @@ public interface UpdateReminderComponent {
@FxmlScene(FxmlFile.UPDATE_REMINDER)
Lazy<Scene> updateReminderScene();
default void showUpdateReminderWindow() {
Stage stage = window();
stage.setScene(updateReminderScene().get());
stage.sizeToScene();
stage.show();
Settings settings();
default void checkAndShowUpdateReminderWindow() {
if (LocalDate.parse(settings().lastUpdateCheck.get()).isBefore(LocalDate.now().minusDays(14)) && !settings().checkForUpdates.getValue()) {
Stage stage = window();
stage.setScene(updateReminderScene().get());
stage.sizeToScene();
stage.show();
}
}
@Subcomponent.Factory