mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-02 20:36:44 +00:00
fix threading issue on terminal wallet load
This commit is contained in:
parent
778564a954
commit
81cde4756a
1 changed files with 28 additions and 26 deletions
|
@ -52,7 +52,10 @@ public class LoadWallet implements Runnable {
|
|||
loadWalletService.setExecutor(Storage.LoadWalletService.getSingleThreadedExecutor());
|
||||
loadWalletService.setOnSucceeded(workerStateEvent -> {
|
||||
WalletAndKey walletAndKey = loadWalletService.getValue();
|
||||
SparrowTerminal.get().getGuiThread().invokeLater(() -> openWallet(storage, walletAndKey));
|
||||
SparrowTerminal.get().getGuiThread().invokeLater(() -> {
|
||||
SparrowTerminal.get().getGui().removeWindow(loadingDialog);
|
||||
Platform.runLater(() -> openWallet(storage, walletAndKey));
|
||||
});
|
||||
});
|
||||
loadWalletService.setOnFailed(workerStateEvent -> {
|
||||
Throwable exception = workerStateEvent.getSource().getException();
|
||||
|
@ -77,7 +80,10 @@ public class LoadWallet implements Runnable {
|
|||
loadWalletService.setOnSucceeded(workerStateEvent -> {
|
||||
EventManager.get().post(new StorageEvent(storage.getWalletId(null), TimedEvent.Action.END, "Done"));
|
||||
WalletAndKey walletAndKey = loadWalletService.getValue();
|
||||
SparrowTerminal.get().getGuiThread().invokeLater(() -> openWallet(storage, walletAndKey));
|
||||
SparrowTerminal.get().getGuiThread().invokeLater(() -> {
|
||||
SparrowTerminal.get().getGui().removeWindow(loadingDialog);
|
||||
Platform.runLater(() -> openWallet(storage, walletAndKey));
|
||||
});
|
||||
});
|
||||
loadWalletService.setOnFailed(workerStateEvent -> {
|
||||
EventManager.get().post(new StorageEvent(storage.getWalletId(null), TimedEvent.Action.END, "Failed"));
|
||||
|
@ -108,8 +114,6 @@ public class LoadWallet implements Runnable {
|
|||
}
|
||||
|
||||
private void openWallet(Storage storage, WalletAndKey walletAndKey) {
|
||||
SparrowTerminal.get().getGui().removeWindow(loadingDialog);
|
||||
|
||||
try {
|
||||
storage.restorePublicKeysFromSeed(walletAndKey.getWallet(), walletAndKey.getKey());
|
||||
if(!walletAndKey.getWallet().isValid()) {
|
||||
|
@ -120,7 +124,7 @@ public class LoadWallet implements Runnable {
|
|||
openWallet(entry.getValue(), entry.getKey());
|
||||
}
|
||||
if(walletAndKey.getWallet().isMasterWallet()) {
|
||||
getOpeningDialog(walletAndKey.getWallet()).showDialog(SparrowTerminal.get().getGui());
|
||||
SparrowTerminal.get().getGuiThread().invokeLater(() -> getOpeningDialog(walletAndKey.getWallet()).showDialog(SparrowTerminal.get().getGui()));
|
||||
}
|
||||
} catch(Exception e) {
|
||||
log.error("Wallet Error", e);
|
||||
|
@ -131,7 +135,6 @@ public class LoadWallet implements Runnable {
|
|||
}
|
||||
|
||||
private void addWallet(Storage storage, Wallet wallet) {
|
||||
Platform.runLater(() -> {
|
||||
if(wallet.isNested()) {
|
||||
WalletData walletData = SparrowTerminal.get().getWalletData().get(wallet.getMasterWallet());
|
||||
WalletForm walletForm = new WalletForm(storage, wallet);
|
||||
|
@ -155,7 +158,6 @@ public class LoadWallet implements Runnable {
|
|||
}
|
||||
|
||||
EventManager.get().post(new WalletOpenedEvent(storage, wallet));
|
||||
});
|
||||
}
|
||||
|
||||
public static DialogWindow getOpeningDialog(Wallet masterWallet) {
|
||||
|
|
Loading…
Reference in a new issue