Skip to content

Commit 549f184

Browse files
committed
do not refresh history if update is in progress
1 parent 27a755b commit 549f184

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,4 +314,4 @@
314314
"prettier": {
315315
"singleQuote": true
316316
}
317-
}
317+
}

src/pages/home/home.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,14 @@ export class HomePage {
182182
this.fetchWalletStatus(opts);
183183
};
184184

185+
186+
private walletActionHandler = opts => {
187+
this.logger.debug('RECV Local/TxAction @home', opts);
188+
opts = opts || {};
189+
opts.alsoUpdateHistory = true;
190+
this.fetchWalletStatus(opts);
191+
};
192+
185193
ionViewDidLoad() {
186194
this.logger.info('Loaded: HomePage');
187195

@@ -202,7 +210,7 @@ export class HomePage {
202210
this.events.subscribe('Local/WalletListChange', this.setWallets);
203211

204212
// Reject, Remove, OnlyPublish and SignAndBroadcast -> Update Status per Wallet -> Update txps
205-
this.events.subscribe('Local/TxAction', this.walletFocusHandler);
213+
this.events.subscribe('Local/TxAction', this.walletActionHandler);
206214

207215
// Wallet is focused on some inner view, therefore, we refresh its status and txs
208216
this.events.subscribe('Local/WalletFocus', this.walletFocusHandler);
@@ -620,8 +628,8 @@ export class HomePage {
620628
}
621629
})
622630
.catch(err => {
631+
if (err == 'INPROGRESS') return;
623632
this.processWalletError(wallet, err);
624-
625633
this.events.publish('Local/WalletUpdate', {
626634
walletId: opts.walletId,
627635
finished: true,
@@ -631,6 +639,7 @@ export class HomePage {
631639
if (opts.alsoUpdateHistory) {
632640
this.fetchTxHistory({ walletId: opts.walletId });
633641
}
642+
634643
});
635644
};
636645

src/providers/wallet/wallet.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,10 @@ export class WalletProvider {
976976
});
977977
}
978978

979+
private isHistoryCached(wallet): boolean {
980+
return wallet.completeHistory && wallet.completeHistoryIsValid;
981+
};
982+
979983
public getTx(wallet, txid: string): Promise<any> {
980984
return new Promise((resolve, reject) => {
981985
const finish = list => {
@@ -987,7 +991,7 @@ export class WalletProvider {
987991
return tx;
988992
};
989993

990-
if (wallet.completeHistory && wallet.completeHistoryIsValid) {
994+
if (this.isHistoryCached(wallet)) {
991995
const tx = finish(wallet.completeHistory);
992996
return resolve(tx);
993997
} else {
@@ -1006,6 +1010,7 @@ export class WalletProvider {
10061010
});
10071011
}
10081012

1013+
10091014
public fetchTxHistory(
10101015
wallet,
10111016
progressFn,
@@ -1016,11 +1021,7 @@ export class WalletProvider {
10161021

10171022
if (!wallet.isComplete()) return resolve();
10181023

1019-
const isHistoryCached = () => {
1020-
return wallet.completeHistory && wallet.completeHistoryIsValid;
1021-
};
1022-
1023-
if (isHistoryCached() && !opts.force) {
1024+
if (this.isHistoryCached(wallet) && !opts.force) {
10241025
return resolve(wallet.completeHistory);
10251026
}
10261027

0 commit comments

Comments
 (0)