From 6dd34b0c63b54c272c57063ceca7f43f39672df8 Mon Sep 17 00:00:00 2001 From: Robert Dyer <rdyer@unl.edu> Date: Thu, 11 Jul 2024 03:32:57 -0500 Subject: [PATCH] Perform bank sync in same order as accounts shown in sidebar. (#3029) --- packages/loot-core/src/client/actions/account.ts | 5 +++++ packages/loot-core/src/server/main.ts | 3 ++- upcoming-release-notes/3029.md | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 upcoming-release-notes/3029.md diff --git a/packages/loot-core/src/client/actions/account.ts b/packages/loot-core/src/client/actions/account.ts index f2c80730d..df0a9c378 100644 --- a/packages/loot-core/src/client/actions/account.ts +++ b/packages/loot-core/src/client/actions/account.ts @@ -95,6 +95,11 @@ export function syncAccounts(id?: string) { .queries.accounts.filter( ({ bank, closed, tombstone }) => !!bank && !closed && !tombstone, ) + .sort((a, b) => + a.offbudget === b.offbudget + ? a.sort_order - b.sort_order + : a.offbudget - b.offbudget, + ) .map(({ id }) => id); dispatch(setAccountsSyncing(accountIdsToSync)); diff --git a/packages/loot-core/src/server/main.ts b/packages/loot-core/src/server/main.ts index 634293646..f6c98e88b 100644 --- a/packages/loot-core/src/server/main.ts +++ b/packages/loot-core/src/server/main.ts @@ -1062,7 +1062,8 @@ handlers['accounts-bank-sync'] = async function ({ id }) { const accounts = await db.runQuery( `SELECT a.*, b.bank_id as bankId FROM accounts a LEFT JOIN banks b ON a.bank = b.id - WHERE a.tombstone = 0 AND a.closed = 0 ${id ? 'AND a.id = ?' : ''}`, + WHERE a.tombstone = 0 AND a.closed = 0 ${id ? 'AND a.id = ?' : ''} + ORDER BY a.offbudget, a.sort_order`, id ? [id] : [], true, ); diff --git a/upcoming-release-notes/3029.md b/upcoming-release-notes/3029.md new file mode 100644 index 000000000..0ad61be82 --- /dev/null +++ b/upcoming-release-notes/3029.md @@ -0,0 +1,6 @@ +--- +category: Enhancements +authors: [psybers] +--- + +Perform bank sync in same order as accounts shown in sidebar. -- GitLab