mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-21 10:14:26 +08:00
show more accurate status messages when reloading all account, category and tag data
This commit is contained in:
@@ -392,17 +392,38 @@ function open(options: { expenseCategoryNames: NameValue[], incomeCategoryNames:
|
|||||||
function reload(): void {
|
function reload(): void {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
|
||||||
Promise.all([
|
Promise.allSettled([
|
||||||
accountsStore.loadAllAccounts({ force: true }),
|
accountsStore.loadAllAccounts({ force: true }),
|
||||||
transactionCategoriesStore.loadAllCategories({ force: true }),
|
transactionCategoriesStore.loadAllCategories({ force: true }),
|
||||||
transactionTagsStore.loadAllTags({ force: true })
|
transactionTagsStore.loadAllTags({ force: true })
|
||||||
]).then(() => {
|
]).then(results => {
|
||||||
loading.value = false;
|
|
||||||
}).catch(error => {
|
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
|
|
||||||
if (!error.processed) {
|
const isAllUpToDate = results.length === 3
|
||||||
snackbar.value?.showError(error);
|
&& results[0].status === 'rejected' && results[0].reason?.isUpToDate
|
||||||
|
&& results[1].status === 'rejected' && results[1].reason?.isUpToDate
|
||||||
|
&& results[2].status === 'rejected' && results[2].reason?.isUpToDate;
|
||||||
|
|
||||||
|
// show info if all up to date
|
||||||
|
if (isAllUpToDate) {
|
||||||
|
snackbar.value?.showMessage('Data is up to date');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// show error if any
|
||||||
|
for (const result of results) {
|
||||||
|
if (result.status === 'rejected' && !result.reason?.isUpToDate) {
|
||||||
|
snackbar.value?.showError(result.reason);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// show info if one of them updated
|
||||||
|
for (const result of results) {
|
||||||
|
if (result.status === 'fulfilled') {
|
||||||
|
snackbar.value?.showMessage('Data has been updated');
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user