@@ -628,13 +628,13 @@ type SyncResponse = {
628628 updatedAccounts : Array < AccountEntity [ 'id' ] > ;
629629} ;
630630
631- function handleSyncResponse (
631+ async function handleSyncResponse (
632632 res : {
633633 added : Array < TransactionEntity [ 'id' ] > ;
634634 updated : Array < TransactionEntity [ 'id' ] > ;
635635 } ,
636636 acct : db . DbAccount ,
637- ) : SyncResponse {
637+ ) : Promise < SyncResponse > {
638638 const { added, updated } = res ;
639639 const newTransactions : Array < TransactionEntity [ 'id' ] > = [ ] ;
640640 const matchedTransactions : Array < TransactionEntity [ 'id' ] > = [ ] ;
@@ -647,6 +647,9 @@ function handleSyncResponse(
647647 updatedAccounts . push ( acct . id ) ;
648648 }
649649
650+ const ts = new Date ( ) . getTime ( ) . toString ( ) ;
651+ await db . update ( 'accounts' , { id : acct . id , last_sync : ts } ) ;
652+
650653 return {
651654 newTransactions,
652655 matchedTransactions,
@@ -745,7 +748,7 @@ async function accountsBankSync({
745748 acct . bankId ,
746749 ) ;
747750
748- const syncResponseData = handleSyncResponse ( syncResponse , acct ) ;
751+ const syncResponseData = await handleSyncResponse ( syncResponse , acct ) ;
749752
750753 newTransactions . push ( ...syncResponseData . newTransactions ) ;
751754 matchedTransactions . push ( ...syncResponseData . matchedTransactions ) ;
@@ -848,7 +851,10 @@ async function simpleFinBatchSync({
848851 ) ,
849852 ) ;
850853 } else {
851- const syncResponseData = handleSyncResponse ( syncResponse . res , account ) ;
854+ const syncResponseData = await handleSyncResponse (
855+ syncResponse . res ,
856+ account ,
857+ ) ;
852858
853859 newTransactions . push ( ...syncResponseData . newTransactions ) ;
854860 matchedTransactions . push ( ...syncResponseData . matchedTransactions ) ;
0 commit comments