mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-05 05:46:44 +00:00
add protection to recursive refresh call
This commit is contained in:
parent
e594007af1
commit
416fc83b4d
1 changed files with 6 additions and 5 deletions
|
@ -247,12 +247,12 @@ public class SparrowDataSource extends WalletResponseDataSource {
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void walletHistoryChanged(WalletHistoryChangedEvent event) {
|
public void walletHistoryChanged(WalletHistoryChangedEvent event) {
|
||||||
refreshWallet(event.getWalletId(), event.getWallet());
|
refreshWallet(event.getWalletId(), event.getWallet(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void walletAddressesChanged(WalletAddressesChangedEvent event) {
|
public void walletAddressesChanged(WalletAddressesChangedEvent event) {
|
||||||
refreshWallet(event.getWalletId(), event.getWallet());
|
refreshWallet(event.getWalletId(), event.getWallet(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
@ -264,13 +264,14 @@ public class SparrowDataSource extends WalletResponseDataSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshWallet(String walletId, Wallet wallet) {
|
private void refreshWallet(String walletId, Wallet wallet, int i) {
|
||||||
try {
|
try {
|
||||||
// match <prefix>:master, :Premix, :Postmix
|
// match <prefix>:master, :Premix, :Postmix
|
||||||
if(walletId.startsWith(walletIdentifierPrefix) && (wallet.isWhirlpoolMasterWallet() || wallet.isWhirlpoolChildWallet())) {
|
if(walletId.startsWith(walletIdentifierPrefix) && (wallet.isWhirlpoolMasterWallet() || wallet.isWhirlpoolChildWallet())) {
|
||||||
|
//Workaround to avoid refreshing the wallet after it has been opened, but before it has been started
|
||||||
Whirlpool whirlpool = AppServices.getWhirlpoolServices().getWhirlpool(wallet);
|
Whirlpool whirlpool = AppServices.getWhirlpoolServices().getWhirlpool(wallet);
|
||||||
if(whirlpool != null && whirlpool.isStarting()) {
|
if(whirlpool != null && whirlpool.isStarting() && i < 1000) {
|
||||||
Platform.runLater(() -> refreshWallet(walletId, wallet));
|
Platform.runLater(() -> refreshWallet(walletId, wallet, i+1));
|
||||||
} else {
|
} else {
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue