From ec5e98b934e1597e1b676654d4d6d8620c15b73b Mon Sep 17 00:00:00 2001 From: Jack <jack@monkeytype.com> Date: Sun, 21 May 2023 19:42:05 +0200 Subject: [PATCH] Fixed a bug where it was possible to make a transfer to the same account as the one making the transfer. (#1038) The payee autocomplete was always using cached accounts. Added a check to see if accounts was already passed in as a parameter - only using cached if it wasnt. --- .../src/components/accounts/TransactionsTable.js | 1 + .../components/autocomplete/PayeeAutocomplete.js | 13 +++++++++++-- upcoming-release-notes/1038.md | 6 ++++++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 upcoming-release-notes/1038.md diff --git a/packages/desktop-client/src/components/accounts/TransactionsTable.js b/packages/desktop-client/src/components/accounts/TransactionsTable.js index 3bf191443..2ececa01b 100644 --- a/packages/desktop-client/src/components/accounts/TransactionsTable.js +++ b/packages/desktop-client/src/components/accounts/TransactionsTable.js @@ -403,6 +403,7 @@ function PayeeCell({ // Filter out the account we're currently in as it is not a valid transfer accounts = accounts.filter(account => account.id !== accountId); + payees = payees.filter(payee => payee.transfer_acct !== accountId); return ( <CustomCell diff --git a/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.js b/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.js index d826bc1fb..86904ff98 100644 --- a/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.js +++ b/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.js @@ -181,10 +181,19 @@ export default function PayeeAutocomplete({ onUpdate, onSelect, onManagePayees, + accounts, + payees, ...props }) { - let payees = useCachedPayees(); - let accounts = useCachedAccounts(); + let cachedPayees = useCachedPayees(); + if (!payees) { + payees = cachedPayees; + } + + let cachedAccounts = useCachedAccounts(); + if (!accounts) { + accounts = cachedAccounts; + } let [focusTransferPayees, setFocusTransferPayees] = useState( defaultFocusTransferPayees, diff --git a/upcoming-release-notes/1038.md b/upcoming-release-notes/1038.md new file mode 100644 index 000000000..8018b0b88 --- /dev/null +++ b/upcoming-release-notes/1038.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [Miodec] +--- + +Fixed a bug where it was possible to make a transfer to the same account as the one making the transfer. -- GitLab