mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-23 20:36:44 +00:00
dont open the same wallet twice
This commit is contained in:
parent
61c3c4a3ac
commit
10edf31e13
1 changed files with 22 additions and 0 deletions
|
@ -810,6 +810,18 @@ public class AppController implements Initializable {
|
|||
if(result.isPresent() && result.get() == ButtonType.CANCEL) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Close existing wallet first if open
|
||||
for(Iterator<Tab> iter = tabs.getTabs().iterator(); iter.hasNext(); ) {
|
||||
Tab tab = iter.next();
|
||||
TabData tabData = (TabData)tab.getUserData();
|
||||
if(tabData.getType() == TabData.TabType.WALLET) {
|
||||
WalletTabData walletTabData = (WalletTabData) tabData;
|
||||
if(walletTabData.getStorage().getWalletFile().equals(walletFile)) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Storage storage = new Storage(walletFile);
|
||||
|
@ -837,6 +849,16 @@ public class AppController implements Initializable {
|
|||
}
|
||||
|
||||
public Tab addWalletTab(Storage storage, Wallet wallet) {
|
||||
for(Tab tab : tabs.getTabs()) {
|
||||
TabData tabData = (TabData)tab.getUserData();
|
||||
if(tabData.getType() == TabData.TabType.WALLET) {
|
||||
WalletTabData walletTabData = (WalletTabData) tabData;
|
||||
if(storage.getWalletFile().equals(walletTabData.getStorage().getWalletFile())) {
|
||||
return tab;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
String name = storage.getWalletFile().getName();
|
||||
if(name.endsWith(".json")) {
|
||||
|
|
Loading…
Reference in a new issue