Fix issue where the UI is stuck sync'ing if no data from server (#3941)

* Fix issue where the UI is stuck sync'ing if no data from server

* add release note
This commit is contained in:
Robert Dyer
2024-12-29 14:49:19 -06:00
committed by GitHub
parent ded2f39e13
commit e6aeea668b
3 changed files with 61 additions and 36 deletions

View File

@@ -205,6 +205,9 @@ async function downloadSimpleFinTransactions(
60000,
);
if (Object.keys(res).length === 0) {
throw BankSyncError('NO_DATA', 'NO_DATA');
}
if (res.error_code) {
throw BankSyncError(res.error_type, res.error_code);
}

View File

@@ -1168,46 +1168,62 @@ handlers['simplefin-batch-sync'] = async function ({ ids = [] }) {
true,
);
console.group('Bank Sync operation for all SimpleFin accounts');
const res = await bankSync.SimpleFinBatchSync(
accounts.map(a => ({
id: a.id,
accountId: a.account_id,
})),
);
const retVal = [];
for (const account of res) {
const errors = [];
const newTransactions = [];
const matchedTransactions = [];
const updatedAccounts = [];
if (account.res.error_code) {
errors.push(
handleSyncError(
{
type: 'BankSyncError',
category: account.res.error_type,
code: account.res.error_code,
},
console.group('Bank Sync operation for all SimpleFin accounts');
try {
const res = await bankSync.SimpleFinBatchSync(
accounts.map(a => ({
id: a.id,
accountId: a.account_id,
})),
);
for (const account of res) {
const errors = [];
const newTransactions = [];
const matchedTransactions = [];
const updatedAccounts = [];
if (account.res.error_code) {
errors.push(
handleSyncError(
{
type: 'BankSyncError',
category: account.res.error_type,
code: account.res.error_code,
},
accounts.find(a => a.id === account.accountId),
),
);
} else {
handleSyncResponse(
account.res,
accounts.find(a => a.id === account.accountId),
),
);
} else {
handleSyncResponse(
account.res,
accounts.find(a => a.id === account.accountId),
newTransactions,
matchedTransactions,
updatedAccounts,
);
}
newTransactions,
matchedTransactions,
updatedAccounts,
);
}
retVal.push({
accountId: account.accountId,
res: { errors, newTransactions, matchedTransactions, updatedAccounts },
});
retVal.push({
accountId: account.accountId,
res: { errors, newTransactions, matchedTransactions, updatedAccounts },
});
}
} catch (err) {
const errors = [];
for (const account of accounts) {
retVal.push({
accountId: account.accountId,
res: {
errors,
newTransactions: [],
matchedTransactions: [],
updatedAccounts: [],
},
});
errors.push(handleSyncError(err, account));
}
}
if (retVal.some(a => a.res.updatedAccounts.length > 0)) {

View File

@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [psybers]
---
Fix UI issue with bank sync being stuck if no data from server.