Skip to content

Commit

Permalink
Bug fix/sync import time (#2554)
Browse files Browse the repository at this point in the history
* added sort order on transactions before filtering

* added import date to preferences coming from sync data of the extension

* correct variable spelling
  • Loading branch information
sethkfman authored Apr 20, 2021
1 parent 3019738 commit 54de5df
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
12 changes: 4 additions & 8 deletions app/components/Views/Asset/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,10 @@ class Asset extends PureComponent {
const confirmedTxs = [];
const { chainId, transactions } = this.props;
if (transactions.length) {
transactions.sort((a, b) => (a.time > b.time ? -1 : b.time > a.time ? 1 : 0));
const txs = transactions.filter(tx => {
const filerResult = this.filter(tx);
if (filerResult) {
const filterResult = this.filter(tx);
if (filterResult) {
tx.insertImportTime = addAccountTimeFlagFilter(
tx,
addedAccountTime,
Expand All @@ -210,13 +211,9 @@ class Asset extends PureComponent {
break;
}
}
return filerResult;
return filterResult;
});

txs.sort((a, b) => (a.time > b.time ? -1 : b.time > a.time ? 1 : 0));
submittedTxs.sort((a, b) => (a.time > b.time ? -1 : b.time > a.time ? 1 : 0));
confirmedTxs.sort((a, b) => (a.time > b.time ? -1 : b.time > a.time ? 1 : 0));

const submittedNonces = [];
submittedTxs = submittedTxs.filter(transaction => {
const alreadySubmitted = submittedNonces.includes(transaction.transaction.nonce);
Expand All @@ -228,7 +225,6 @@ class Asset extends PureComponent {
if (!accountAddedTimeInsertPointFound && txs && txs.length) {
txs[txs.length - 1].insertImportTime = true;
}

// To avoid extra re-renders we want to set the new txs only when
// there's a new tx in the history or the status of one of the existing txs changed
if (
Expand Down
1 change: 1 addition & 0 deletions app/core/Engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ class Engine {
const checksummedAddress = toChecksumAddress(address);
if (accounts.hd.includes(checksummedAddress) || accounts.simpleKeyPair.includes(checksummedAddress)) {
updatedPref.identities[checksummedAddress] = preferences.identities[address];
updatedPref.identities[checksummedAddress].importTime = Date.now();
}
});
await PreferencesController.update(updatedPref);
Expand Down

0 comments on commit 54de5df

Please sign in to comment.