show whether data is updated after pull down

This commit is contained in:
MaysWind
2023-06-18 22:43:47 +08:00
parent 55ad7b2e81
commit eb2e2b0a26
15 changed files with 102 additions and 17 deletions
+8 -3
View File
@@ -6,7 +6,7 @@ import { useExchangeRatesStore } from './exchangeRates.js';
import accountConstants from '@/consts/account.js';
import services from '@/lib/services.js';
import logger from '@/lib/logger.js';
import { isNumber } from '@/lib/common.js';
import { isNumber, isEquals } from '@/lib/common.js';
import { getCategorizedAccounts, getAllFilteredAccountsBalance } from '@/lib/account.js';
function loadAccountList(state, accounts) {
@@ -537,12 +537,17 @@ export const useAccountsStore = defineStore('accounts', {
return;
}
loadAccountList(self, data.result);
if (self.accountListStateInvalid) {
self.updateAccountListInvalidState(false);
}
if (force && data.result && isEquals(self.allAccounts, data.result)) {
reject({ message: 'Account list is up to date' });
return;
}
loadAccountList(self, data.result);
resolve(data.result);
}).catch(error => {
if (force) {
+1 -1
View File
@@ -81,7 +81,7 @@ export const useExchangeRatesStore = defineStore('exchangeRates', {
const currentData = getExchangeRatesFromLocalStorage();
if (currentData && currentData.data && isEquals(currentData.data, data.result)) {
if (force && currentData && currentData.data && isEquals(currentData.data, data.result)) {
reject({ message: 'Exchange rates data is up to date' });
return;
}
+8 -3
View File
@@ -2,9 +2,9 @@ import { defineStore } from 'pinia';
import { useExchangeRatesStore } from './exchangeRates.js';
import { isNumber, isEquals } from '@/lib/common.js';
import services from '@/lib/services.js';
import logger from '@/lib/logger.js';
import { isNumber } from '@/lib/common.js';
export const useOverviewStore = defineStore('overview', {
state: () => ({
@@ -91,12 +91,17 @@ export const useOverviewStore = defineStore('overview', {
item.incompleteExpenseAmount = hasUnCalculatedTotalExpense;
}
self.transactionOverview = overview;
if (self.transactionOverviewStateInvalid) {
self.updateTransactionOverviewInvalidState(false);
}
if (force && overview && isEquals(self.transactionOverview, overview)) {
reject({ message: 'Data is up to date' });
return;
}
self.transactionOverview = overview;
resolve(overview);
}).catch(error => {
if (force) {
+8 -2
View File
@@ -1,6 +1,7 @@
import { defineStore } from 'pinia';
import categoryConstants from '@/consts/category.js';
import { isEquals } from '@/lib/common.js';
import services from '@/lib/services.js';
import logger from '@/lib/logger.js';
@@ -179,12 +180,17 @@ export const useTransactionCategoriesStore = defineStore('transactionCategories'
}
}
loadTransactionCategoryList(self, data.result);
if (self.transactionCategoryListStateInvalid) {
self.updateTransactionCategoryListInvalidState(false);
}
if (force && data.result && isEquals(self.allTransactionCategories, data.result)) {
reject({ message: 'Category list is up to date' });
return;
}
loadTransactionCategoryList(self, data.result);
resolve(data.result);
}).catch(error => {
if (force) {
+8 -2
View File
@@ -1,5 +1,6 @@
import { defineStore } from 'pinia';
import { isEquals } from '@/lib/common.js';
import services from '@/lib/services.js';
import logger from '@/lib/logger.js';
@@ -85,12 +86,17 @@ export const useTransactionTagsStore = defineStore('transactionTags', {
return;
}
loadTransactionTagList(self, data.result);
if (self.transactionTagListStateInvalid) {
self.updateTransactionTagListInvalidState(false);
}
if (force && data.result && isEquals(self.allTransactionTags, data.result)) {
reject({ message: 'Tag list is up to date' });
return;
}
loadTransactionTagList(self, data.result);
resolve(data.result);
}).catch(error => {
if (force) {