Skip to content

Commit

Permalink
Fixes issue with applying changes to past operations
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasFlamel1 committed Nov 23, 2022
1 parent b758e20 commit 8d2248d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,6 @@ export const scanAccounts = makeScanAccounts({
});

export const sync = makeSync({
getAccountShape
getAccountShape,
shouldMergeOps: false
});
42 changes: 30 additions & 12 deletions libs/ledger-live-common/src/reconciliation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,36 @@ export function patchAccount(
}
}

const operations = patchOperations(
account.operations,
updatedRaw.operations,
updatedRaw.id,
subAccounts
);
const pendingOperations = patchOperations(
account.pendingOperations,
updatedRaw.pendingOperations,
updatedRaw.id,
subAccounts
);
let shouldMergeOps: boolean;
switch (account.currency.family) {
case "mimblewimble_coin":
shouldMergeOps = false;
break;
default:
shouldMergeOps = true;
break;
}
let operations: Operation[];
let pendingOperations: Operation[];
if (shouldMergeOps) {
operations = patchOperations(
account.operations,
updatedRaw.operations,
updatedRaw.id,
subAccounts
);
pendingOperations = patchOperations(
account.pendingOperations,
updatedRaw.pendingOperations,
updatedRaw.id,
subAccounts
);
}
else {
operations = updatedRaw.operations.map(raw => fromOperationRaw(raw, updatedRaw.id, subAccounts));
pendingOperations = updatedRaw.pendingOperations.map(raw => fromOperationRaw(raw, updatedRaw.id, subAccounts));
}

const next: Account = { ...account };
let changed = false;

Expand Down

0 comments on commit 8d2248d

Please sign in to comment.