mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +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) {
|
if(result.isPresent() && result.get() == ButtonType.CANCEL) {
|
||||||
return;
|
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);
|
Storage storage = new Storage(walletFile);
|
||||||
|
@ -837,6 +849,16 @@ public class AppController implements Initializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tab addWalletTab(Storage storage, Wallet wallet) {
|
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 {
|
try {
|
||||||
String name = storage.getWalletFile().getName();
|
String name = storage.getWalletFile().getName();
|
||||||
if(name.endsWith(".json")) {
|
if(name.endsWith(".json")) {
|
||||||
|
|
Loading…
Reference in a new issue