mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-24 12:46:45 +00:00
ensure order of unencrypted wallet tabs is retained across restarts
This commit is contained in:
parent
58cd50f674
commit
d9bba16eb6
2 changed files with 15 additions and 0 deletions
|
@ -893,6 +893,7 @@ public class AppController implements Initializable {
|
|||
Storage storage = new Storage(file);
|
||||
if(!storage.isEncrypted()) {
|
||||
Storage.LoadWalletService loadWalletService = new Storage.LoadWalletService(storage);
|
||||
loadWalletService.setExecutor(Storage.LoadWalletService.getSingleThreadedExecutor());
|
||||
loadWalletService.setOnSucceeded(workerStateEvent -> {
|
||||
WalletAndKey walletAndKey = loadWalletService.getValue();
|
||||
openWallet(storage, walletAndKey, this, forceSameWindow);
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.sparrowwallet.drongo.wallet.Wallet;
|
|||
import com.sparrowwallet.sparrow.MainApp;
|
||||
import javafx.concurrent.Service;
|
||||
import javafx.concurrent.Task;
|
||||
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
|
||||
import org.controlsfx.tools.Platform;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -22,6 +23,8 @@ import java.security.cert.CertificateEncodingException;
|
|||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -509,6 +512,8 @@ public class Storage {
|
|||
private final Storage storage;
|
||||
private final SecureString password;
|
||||
|
||||
private static Executor singleThreadedExecutor;
|
||||
|
||||
public LoadWalletService(Storage storage) {
|
||||
this.storage = storage;
|
||||
this.password = null;
|
||||
|
@ -536,6 +541,15 @@ public class Storage {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Executor getSingleThreadedExecutor() {
|
||||
if(singleThreadedExecutor == null) {
|
||||
BasicThreadFactory factory = new BasicThreadFactory.Builder().namingPattern("LoadWalletService-single").daemon(true).priority(Thread.MIN_PRIORITY).build();
|
||||
singleThreadedExecutor = Executors.newSingleThreadScheduledExecutor(factory);
|
||||
}
|
||||
|
||||
return singleThreadedExecutor;
|
||||
}
|
||||
}
|
||||
|
||||
public static class KeyDerivationService extends Service<ECKey> {
|
||||
|
|
Loading…
Reference in a new issue