From 78afc5e4d50686af4e57b6e8496610a3800be785 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 11 Oct 2022 15:26:14 +0200 Subject: [PATCH] fix no recent wallets issue --- .../sparrow/terminal/MasterActionListBox.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/terminal/MasterActionListBox.java b/src/main/java/com/sparrowwallet/sparrow/terminal/MasterActionListBox.java index b0e2e208..bed2bffe 100644 --- a/src/main/java/com/sparrowwallet/sparrow/terminal/MasterActionListBox.java +++ b/src/main/java/com/sparrowwallet/sparrow/terminal/MasterActionListBox.java @@ -27,17 +27,19 @@ public class MasterActionListBox extends ActionListBox { addItem("Wallets", () -> { ActionListDialogBuilder builder = new ActionListDialogBuilder(); builder.setTitle("Wallets"); - for(int i = 0; i < Config.get().getRecentWalletFiles().size() && i < MAX_RECENT_WALLETS; i++) { - File recentWalletFile = Config.get().getRecentWalletFiles().get(i); - Storage storage = new Storage(recentWalletFile); + if(Config.get().getRecentWalletFiles() != null) { + for(int i = 0; i < Config.get().getRecentWalletFiles().size() && i < MAX_RECENT_WALLETS; i++) { + File recentWalletFile = Config.get().getRecentWalletFiles().get(i); + Storage storage = new Storage(recentWalletFile); - Optional optWallet = AppServices.get().getOpenWallets().entrySet().stream() - .filter(entry -> entry.getValue().getWalletFile().equals(recentWalletFile)).map(Map.Entry::getKey) - .map(wallet -> wallet.isMasterWallet() ? wallet : wallet.getMasterWallet()).findFirst(); - if(optWallet.isPresent()) { - builder.addAction(storage.getWalletName(null) + "*", () -> LoadWallet.getOpeningDialog(optWallet.get()).showDialog(SparrowTerminal.get().getGui())); - } else { - builder.addAction(storage.getWalletName(null), new LoadWallet(storage)); + Optional optWallet = AppServices.get().getOpenWallets().entrySet().stream() + .filter(entry -> entry.getValue().getWalletFile().equals(recentWalletFile)).map(Map.Entry::getKey) + .map(wallet -> wallet.isMasterWallet() ? wallet : wallet.getMasterWallet()).findFirst(); + if(optWallet.isPresent()) { + builder.addAction(storage.getWalletName(null) + "*", () -> LoadWallet.getOpeningDialog(optWallet.get()).showDialog(SparrowTerminal.get().getGui())); + } else { + builder.addAction(storage.getWalletName(null), new LoadWallet(storage)); + } } } builder.addAction("Open Wallet...", () -> {