fix update from server

This commit is contained in:
JDonadio 2017-11-09 16:22:27 -03:00
parent 37daf6b490
commit 7fb85cb468
No known key found for this signature in database
GPG Key ID: EC1F4E04B2BFA730
2 changed files with 3 additions and 4 deletions

View File

@ -32,7 +32,7 @@ export class WalletDetailsPage {
if (force) this.wallet.completeHistory = [];
this.walletProvider.getTxHistory_(this.wallet, {force: force}).then((txh) => {
this.wallet.completeHistory = this.wallet.completeHistory = txh;
this.wallet.completeHistory = txh;
}).catch((err) => {
console.log(err);
});

View File

@ -392,14 +392,13 @@ export class WalletProvider {
}
private updateTxHistory_(wallet: any, txsFromLocal: any, txsFromServer?: any) {
let array = lodash.compact(txsFromLocal.concat(txsFromServer));
let array = lodash.compact(txsFromLocal.concat(lodash.map(txsFromServer, 'res')));
let newHistory = lodash.uniqBy(array, (x: any) => {
return x.txid;
});
wallet.completeHistory = newHistory;
wallet.completeHistory.isValid = true;
let historyToSave = lodash.compact(lodash.flatten(lodash.map(newHistory, 'res')));
let historyToSave = lodash.compact(lodash.flatten(newHistory));
this.persistenceProvider.setTxHistory(wallet.credentials.walletId, JSON.stringify(historyToSave)).then(() => {
this.logger.debug('Tx History saved for: ' + wallet.credentials.walletId);