Skip to content

Commit

Permalink
Refresh transactions if edited tx has amount changed
Browse files Browse the repository at this point in the history
  • Loading branch information
ystxn committed Oct 26, 2023
1 parent 518c217 commit 54f6497
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/transactions/add-transaction-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,12 @@ const AddTransactionDialog = ({
endpoint([ tx ], (response) => {
const minDate = dayjs.min(response.map(t => dayjs.utc(t.date)));
if (transactionToEdit) {
postProcess(response, transactions.map((t) => response.find((r) => r.id === t.id) || t));
const existing = transactions.find(({ id }) => id === tx.id);
if (existing.amount === tx.amount) {
postProcess(response, transactions.map((t) => response.find((r) => r.id === t.id) || t));
} else {
listTransactions(selectedAccount?.id, (allTx) => postProcess(response, allTx));
}
} else if (minDate.isAfter(maxDate)) {
postProcess(response, [ ...transactions, ...response ]);
} else {
Expand Down

0 comments on commit 54f6497

Please sign in to comment.