From 31f287125f776504f8c8826b1930cf142163eb3b Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Fri, 6 Sep 2024 13:04:22 +0200 Subject: [PATCH] delay show password dialog until initial app window open has completed --- .../sparrowwallet/sparrow/SparrowDesktop.java | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/SparrowDesktop.java b/src/main/java/com/sparrowwallet/sparrow/SparrowDesktop.java index 4e0ba0c9..8002db82 100644 --- a/src/main/java/com/sparrowwallet/sparrow/SparrowDesktop.java +++ b/src/main/java/com/sparrowwallet/sparrow/SparrowDesktop.java @@ -89,28 +89,31 @@ public void start(Stage stage) throws Exception { AppController appController = AppServices.newAppWindow(stage); - if(createNewWallet) { - appController.newWallet(null); - } + final boolean showNewWallet = createNewWallet; + javafx.application.Platform.runLater(() -> { + if(showNewWallet) { + appController.newWallet(null); + } - List recentWalletFiles = Config.get().getRecentWalletFiles(); - if(recentWalletFiles != null) { - //Preserve wallet order as far as possible. Unencrypted wallets will still be opened first. - List encryptedWalletFiles = recentWalletFiles.stream().filter(Storage::isEncrypted).collect(Collectors.toList()); - List sortedWalletFiles = new ArrayList<>(recentWalletFiles); - sortedWalletFiles.removeAll(encryptedWalletFiles); - sortedWalletFiles.addAll(encryptedWalletFiles); - - for(File walletFile : sortedWalletFiles) { - if(walletFile.exists()) { - appController.openWalletFile(walletFile, false); + List recentWalletFiles = Config.get().getRecentWalletFiles(); + if(recentWalletFiles != null) { + //Preserve wallet order as far as possible. Unencrypted wallets will still be opened first. + List encryptedWalletFiles = recentWalletFiles.stream().filter(Storage::isEncrypted).collect(Collectors.toList()); + List sortedWalletFiles = new ArrayList<>(recentWalletFiles); + sortedWalletFiles.removeAll(encryptedWalletFiles); + sortedWalletFiles.addAll(encryptedWalletFiles); + + for(File walletFile : sortedWalletFiles) { + if(walletFile.exists()) { + appController.openWalletFile(walletFile, false); + } } } - } - AppServices.openFileUriArgumentsAfterWalletLoading(stage); + AppServices.openFileUriArgumentsAfterWalletLoading(stage); - AppServices.get().start(); + AppServices.get().start(); + }); } @Override