Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

Commit

Permalink
reconcilation: a change of Token#parentId will restore all
Browse files Browse the repository at this point in the history
  • Loading branch information
gre committed Jun 7, 2019
1 parent 471ad33 commit 574300d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/families/ethereum/libcore-buildTokenAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ async function buildERC20TokenAccount({
})
);

// TODO keep reference if no operation have changed, nor id/token/balance
const tokenAccount: $Exact<TokenAccount> = {
type: "TokenAccount",
id,
Expand Down
8 changes: 7 additions & 1 deletion src/reconciliation.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
// libcore reconciliation by the React definition. https://reactjs.org/docs/reconciliation.html
// TODO move to account/

import isEqual from "lodash/isEqual";
import { BigNumber } from "bignumber.js";
Expand Down Expand Up @@ -243,8 +244,13 @@ export function patchTokenAccount(
updatedRaw: TokenAccountRaw
): TokenAccount {
// id can change after a sync typically if changing the version or filling more info. in that case we consider all changes.
if (!account || account.id !== updatedRaw.id)
if (
!account ||
account.id !== updatedRaw.id ||
account.parentId !== updatedRaw.parentId
) {
return fromTokenAccountRaw(updatedRaw);
}

const operations = patchOperations(
account.operations,
Expand Down

0 comments on commit 574300d

Please sign in to comment.