A local-first personal finance app
Capture sync time for initial account linking Fixes #7282 (#7347)
JkBoyo580929257967
diff --git a/packages/loot-core/src/server/accounts/app.ts b/packages/loot-core/src/server/accounts/app.tsindex 8bb6eaba4f..3e2e831004 100644--- a/packages/loot-core/src/server/accounts/app.ts+++ b/packages/loot-core/src/server/accounts/app.ts@@ -196,7 +196,7 @@ async function linkGoCardlessAccount({});}- await bankSync.syncAccount(+ const syncRes = await bankSync.syncAccount(undefined,undefined,id,@@ -206,6 +206,8 @@ async function linkGoCardlessAccount({startingBalance,);+ await handleSyncResponse(syncRes, id);+connection.send('sync-event', {type: 'success',tables: ['transactions'],@@ -268,7 +270,7 @@ async function linkSimpleFinAccount({});}- await bankSync.syncAccount(+ const syncRes = await bankSync.syncAccount(undefined,undefined,id,@@ -278,6 +280,8 @@ async function linkSimpleFinAccount({startingBalance,);+ await handleSyncResponse(syncRes, id);+connection.send('sync-event', {type: 'success',tables: ['transactions'],@@ -340,7 +344,7 @@ async function linkPluggyAiAccount({});}- await bankSync.syncAccount(+ const syncRes = await bankSync.syncAccount(undefined,undefined,id,@@ -350,6 +354,8 @@ async function linkPluggyAiAccount({startingBalance,);+ await handleSyncResponse(syncRes, id);+connection.send('sync-event', {type: 'success',tables: ['transactions'],@@ -845,7 +851,7 @@ async function handleSyncResponse(added: Array<TransactionEntity['id']>;updated: Array<TransactionEntity['id']>;},- acct: db.DbAccount,+ acctId: string,): Promise<SyncResponse> {const { added, updated } = res;const newTransactions: Array<TransactionEntity['id']> = [];@@ -856,11 +862,11 @@ async function handleSyncResponse(matchedTransactions.push(...updated);if (added.length > 0) {- updatedAccounts.push(acct.id);+ updatedAccounts.push(acctId);}const ts = new Date().getTime().toString();- await db.update('accounts', { id: acct.id, last_sync: ts });+ await db.update('accounts', { id: acctId, last_sync: ts });return {newTransactions,@@ -982,7 +988,10 @@ async function accountsBankSync({acct.bankId,);- const syncResponseData = await handleSyncResponse(syncResponse, acct);+ const syncResponseData = await handleSyncResponse(+ syncResponse,+ acct.id,+ );newTransactions.push(...syncResponseData.newTransactions);matchedTransactions.push(...syncResponseData.matchedTransactions);@@ -1085,7 +1094,7 @@ async function simpleFinBatchSync({} else if (syncResponse.res) {const syncResponseData = await handleSyncResponse(syncResponse.res,- account,+ account.id,);newTransactions.push(...syncResponseData.newTransactions);diff --git a/upcoming-release-notes/7347.md b/upcoming-release-notes/7347.mdnew file mode 100644index 0000000000..3683de4bcd--- /dev/null+++ b/upcoming-release-notes/7347.md@@ -0,0 +1,6 @@+---+category: Bugfixes+authors: [JkBoyo]+---++Update code to record timestamp from account linking using handleSyncResponse.