Преглед изворни кода

moved logic of update checking from FxApplication class to UpdateReminderComponent

Jan-Peter Klein пре 1 година
родитељ
комит
0a07103a4f

+ 1 - 4
src/main/java/org/cryptomator/ui/fxapp/FxApplication.java

@@ -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);

+ 2 - 2
src/main/java/org/cryptomator/ui/fxapp/FxApplicationWindows.java

@@ -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) {

+ 11 - 5
src/main/java/org/cryptomator/ui/updatereminder/UpdateReminderComponent.java

@@ -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