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
+10
View File
@@ -812,6 +812,8 @@ export default {
'This Year': 'This Year', 'This Year': 'This Year',
'Monthly income': 'Monthly income', 'Monthly income': 'Monthly income',
'Unable to get transaction overview': 'Unable to get transaction overview', 'Unable to get transaction overview': 'Unable to get transaction overview',
'Data is up to date': 'Data is up to date',
'Data has been updated': 'Data has been updated',
'Net assets': 'Net assets', 'Net assets': 'Net assets',
'Total assets': 'Total assets', 'Total assets': 'Total assets',
'Total liabilities': 'Total liabilities', 'Total liabilities': 'Total liabilities',
@@ -826,6 +828,8 @@ export default {
'Receivables': 'Receivables', 'Receivables': 'Receivables',
'Investment Account': 'Investment Account', 'Investment Account': 'Investment Account',
'Unable to get account list': 'Unable to get account list', 'Unable to get account list': 'Unable to get account list',
'Account list is up to date': 'Account list is up to date',
'Account list has been updated': 'Account list has been updated',
'No available account': 'No available account', 'No available account': 'No available account',
'Add Account': 'Add Account', 'Add Account': 'Add Account',
'Edit Account': 'Edit Account', 'Edit Account': 'Edit Account',
@@ -989,6 +993,8 @@ export default {
'Device & Sessions': 'Device & Sessions', 'Device & Sessions': 'Device & Sessions',
'Logout All': 'Logout All', 'Logout All': 'Logout All',
'Unable to get session list': 'Unable to get session list', 'Unable to get session list': 'Unable to get session list',
'Session list is up to date': 'Session list is up to date',
'Session list has been updated': 'Session list has been updated',
'Current': 'Current', 'Current': 'Current',
'Other Device': 'Other Device', 'Other Device': 'Other Device',
'Unknown Device': 'Unknown Device', 'Unknown Device': 'Unknown Device',
@@ -1008,6 +1014,8 @@ export default {
'Add Default Categories': 'Add Default Categories', 'Add Default Categories': 'Add Default Categories',
'Default Categories': 'Default Categories', 'Default Categories': 'Default Categories',
'Unable to get category list': 'Unable to get category list', 'Unable to get category list': 'Unable to get category list',
'Category list is up to date': 'Category list is up to date',
'Category list has been updated': 'Category list has been updated',
'Unable to move category': 'Unable to move category', 'Unable to move category': 'Unable to move category',
'Unable to hide this category': 'Unable to hide this category', 'Unable to hide this category': 'Unable to hide this category',
'Unable to unhide this category': 'Unable to unhide this category', 'Unable to unhide this category': 'Unable to unhide this category',
@@ -1035,6 +1043,8 @@ export default {
'Tag Title': 'Tag Title', 'Tag Title': 'Tag Title',
'No available tag': 'No available tag', 'No available tag': 'No available tag',
'Unable to get tag list': 'Unable to get tag list', 'Unable to get tag list': 'Unable to get tag list',
'Tag list is up to date': 'Tag list is up to date',
'Tag list has been updated': 'Tag list has been updated',
'Unable to add tag': 'Unable to add tag', 'Unable to add tag': 'Unable to add tag',
'Unable to save tag': 'Unable to save tag', 'Unable to save tag': 'Unable to save tag',
'Unable to move tag': 'Unable to move tag', 'Unable to move tag': 'Unable to move tag',
+10
View File
@@ -812,6 +812,8 @@ export default {
'This Year': '今年', 'This Year': '今年',
'Monthly income': '当月收入', 'Monthly income': '当月收入',
'Unable to get transaction overview': '无法获取交易概要', 'Unable to get transaction overview': '无法获取交易概要',
'Data is up to date': '数据已是最新',
'Data has been updated': '数据已更新',
'Net assets': '净资产', 'Net assets': '净资产',
'Total assets': '总资产', 'Total assets': '总资产',
'Total liabilities': '总负债', 'Total liabilities': '总负债',
@@ -826,6 +828,8 @@ export default {
'Receivables': '应收款项', 'Receivables': '应收款项',
'Investment Account': '投资账户', 'Investment Account': '投资账户',
'Unable to get account list': '无法获取账户列表', 'Unable to get account list': '无法获取账户列表',
'Account list is up to date': '账户列表已是最新',
'Account list has been updated': '账户列表已更新',
'No available account': '没有可用的账户', 'No available account': '没有可用的账户',
'Add Account': '添加账户', 'Add Account': '添加账户',
'Edit Account': '编辑账户', 'Edit Account': '编辑账户',
@@ -989,6 +993,8 @@ export default {
'Device & Sessions': '设备和会话', 'Device & Sessions': '设备和会话',
'Logout All': '注销全部', 'Logout All': '注销全部',
'Unable to get session list': '无法获取会话列表', 'Unable to get session list': '无法获取会话列表',
'Session list is up to date': '会话列表已是最新',
'Session list has been updated': '会话列表已更新',
'Current': '当前', 'Current': '当前',
'Other Device': '其他设备', 'Other Device': '其他设备',
'Unknown Device': '未知设备', 'Unknown Device': '未知设备',
@@ -1008,6 +1014,8 @@ export default {
'Add Default Categories': '添加默认分类', 'Add Default Categories': '添加默认分类',
'Default Categories': '默认分类', 'Default Categories': '默认分类',
'Unable to get category list': '无法获取分类列表', 'Unable to get category list': '无法获取分类列表',
'Category list is up to date': '分类列表已是最新',
'Category list has been updated': '分类列表已更新',
'Unable to move category': '无法移动分类', 'Unable to move category': '无法移动分类',
'Unable to hide this category': '无法隐藏该分类', 'Unable to hide this category': '无法隐藏该分类',
'Unable to unhide this category': '无法取消隐藏该分类', 'Unable to unhide this category': '无法取消隐藏该分类',
@@ -1035,6 +1043,8 @@ export default {
'Tag Title': '标签标题', 'Tag Title': '标签标题',
'No available tag': '没有可用的标签', 'No available tag': '没有可用的标签',
'Unable to get tag list': '无法获取标签列表', 'Unable to get tag list': '无法获取标签列表',
'Tag list is up to date': '标签列表已是最新',
'Tag list has been updated': '标签列表已更新',
'Unable to add tag': '无法添加标签', 'Unable to add tag': '无法添加标签',
'Unable to save tag': '无法保存标签', 'Unable to save tag': '无法保存标签',
'Unable to move tag': '无法移动标签', 'Unable to move tag': '无法移动标签',
+8 -3
View File
@@ -6,7 +6,7 @@ import { useExchangeRatesStore } from './exchangeRates.js';
import accountConstants from '@/consts/account.js'; import accountConstants from '@/consts/account.js';
import services from '@/lib/services.js'; import services from '@/lib/services.js';
import logger from '@/lib/logger.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'; import { getCategorizedAccounts, getAllFilteredAccountsBalance } from '@/lib/account.js';
function loadAccountList(state, accounts) { function loadAccountList(state, accounts) {
@@ -537,12 +537,17 @@ export const useAccountsStore = defineStore('accounts', {
return; return;
} }
loadAccountList(self, data.result);
if (self.accountListStateInvalid) { if (self.accountListStateInvalid) {
self.updateAccountListInvalidState(false); 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); resolve(data.result);
}).catch(error => { }).catch(error => {
if (force) { if (force) {
+1 -1
View File
@@ -81,7 +81,7 @@ export const useExchangeRatesStore = defineStore('exchangeRates', {
const currentData = getExchangeRatesFromLocalStorage(); 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' }); reject({ message: 'Exchange rates data is up to date' });
return; return;
} }
+8 -3
View File
@@ -2,9 +2,9 @@ import { defineStore } from 'pinia';
import { useExchangeRatesStore } from './exchangeRates.js'; import { useExchangeRatesStore } from './exchangeRates.js';
import { isNumber, isEquals } from '@/lib/common.js';
import services from '@/lib/services.js'; import services from '@/lib/services.js';
import logger from '@/lib/logger.js'; import logger from '@/lib/logger.js';
import { isNumber } from '@/lib/common.js';
export const useOverviewStore = defineStore('overview', { export const useOverviewStore = defineStore('overview', {
state: () => ({ state: () => ({
@@ -91,12 +91,17 @@ export const useOverviewStore = defineStore('overview', {
item.incompleteExpenseAmount = hasUnCalculatedTotalExpense; item.incompleteExpenseAmount = hasUnCalculatedTotalExpense;
} }
self.transactionOverview = overview;
if (self.transactionOverviewStateInvalid) { if (self.transactionOverviewStateInvalid) {
self.updateTransactionOverviewInvalidState(false); self.updateTransactionOverviewInvalidState(false);
} }
if (force && overview && isEquals(self.transactionOverview, overview)) {
reject({ message: 'Data is up to date' });
return;
}
self.transactionOverview = overview;
resolve(overview); resolve(overview);
}).catch(error => { }).catch(error => {
if (force) { if (force) {
+8 -2
View File
@@ -1,6 +1,7 @@
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import categoryConstants from '@/consts/category.js'; import categoryConstants from '@/consts/category.js';
import { isEquals } from '@/lib/common.js';
import services from '@/lib/services.js'; import services from '@/lib/services.js';
import logger from '@/lib/logger.js'; import logger from '@/lib/logger.js';
@@ -179,12 +180,17 @@ export const useTransactionCategoriesStore = defineStore('transactionCategories'
} }
} }
loadTransactionCategoryList(self, data.result);
if (self.transactionCategoryListStateInvalid) { if (self.transactionCategoryListStateInvalid) {
self.updateTransactionCategoryListInvalidState(false); 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); resolve(data.result);
}).catch(error => { }).catch(error => {
if (force) { if (force) {
+8 -2
View File
@@ -1,5 +1,6 @@
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import { isEquals } from '@/lib/common.js';
import services from '@/lib/services.js'; import services from '@/lib/services.js';
import logger from '@/lib/logger.js'; import logger from '@/lib/logger.js';
@@ -85,12 +86,17 @@ export const useTransactionTagsStore = defineStore('transactionTags', {
return; return;
} }
loadTransactionTagList(self, data.result);
if (self.transactionTagListStateInvalid) { if (self.transactionTagListStateInvalid) {
self.updateTransactionTagListInvalidState(false); 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); resolve(data.result);
}).catch(error => { }).catch(error => {
if (force) { if (force) {
+6 -1
View File
@@ -353,15 +353,20 @@ export default {
}, },
reload(done) { reload(done) {
const self = this; const self = this;
const force = !!done;
self.overviewStore.loadTransactionOverview({ self.overviewStore.loadTransactionOverview({
defaultCurrency: self.defaultCurrency, defaultCurrency: self.defaultCurrency,
dateRange: self.dateRange, dateRange: self.dateRange,
force: true force: force
}).then(() => { }).then(() => {
if (done) { if (done) {
done(); done();
} }
if (force) {
self.$toast('Data has been updated');
}
}).catch(error => { }).catch(error => {
if (done) { if (done) {
done(); done();
+6 -1
View File
@@ -267,13 +267,18 @@ export default {
} }
const self = this; const self = this;
const force = !!done;
self.accountsStore.loadAllAccounts({ self.accountsStore.loadAllAccounts({
force: true force: force
}).then(() => { }).then(() => {
if (done) { if (done) {
done(); done();
} }
if (force) {
self.$toast('Account list has been updated');
}
}).catch(error => { }).catch(error => {
if (done) { if (done) {
done(); done();
+6 -1
View File
@@ -58,13 +58,18 @@ export default {
}, },
reload(done) { reload(done) {
const self = this; const self = this;
const force = !!done;
self.transactionCategoriesStore.loadAllCategories({ self.transactionCategoriesStore.loadAllCategories({
force: true force: force
}).then(() => { }).then(() => {
if (done) { if (done) {
done(); done();
} }
if (force) {
self.$toast('Category list has been updated');
}
}).catch(error => { }).catch(error => {
if (done) { if (done) {
done(); done();
+6 -1
View File
@@ -242,13 +242,18 @@ export default {
} }
const self = this; const self = this;
const force = !!done;
self.transactionCategoriesStore.loadAllCategories({ self.transactionCategoriesStore.loadAllCategories({
force: true force: force
}).then(() => { }).then(() => {
if (done) { if (done) {
done(); done();
} }
if (force) {
self.$toast('Category list has been updated');
}
}).catch(error => { }).catch(error => {
if (done) { if (done) {
done(); done();
@@ -496,6 +496,7 @@ export default {
}, },
reload(done) { reload(done) {
const self = this; const self = this;
const force = !!done;
let dispatchPromise = null; let dispatchPromise = null;
if (self.query.chartDataType === self.allChartDataTypes.ExpenseByAccount.type || if (self.query.chartDataType === self.allChartDataTypes.ExpenseByAccount.type ||
@@ -510,7 +511,7 @@ export default {
} else if (self.query.chartDataType === self.allChartDataTypes.AccountTotalAssets.type || } else if (self.query.chartDataType === self.allChartDataTypes.AccountTotalAssets.type ||
self.query.chartDataType === self.allChartDataTypes.AccountTotalLiabilities.type) { self.query.chartDataType === self.allChartDataTypes.AccountTotalLiabilities.type) {
dispatchPromise = self.accountsStore.loadAllAccounts({ dispatchPromise = self.accountsStore.loadAllAccounts({
force: true force: force
}); });
} }
@@ -519,6 +520,10 @@ export default {
if (done) { if (done) {
done(); done();
} }
if (force) {
self.$toast('Data has been updated');
}
}).catch(error => { }).catch(error => {
if (done) { if (done) {
done(); done();
+6 -1
View File
@@ -238,13 +238,18 @@ export default {
} }
const self = this; const self = this;
const force = !!done;
self.transactionTagsStore.loadAllTags({ self.transactionTagsStore.loadAllTags({
force: true force: force
}).then(() => { }).then(() => {
if (done) { if (done) {
done(); done();
} }
if (force) {
self.$toast('Tag list has been updated');
}
}).catch(error => { }).catch(error => {
if (done) { if (done) {
done(); done();
@@ -590,6 +590,7 @@ export default {
}, },
reload(done) { reload(done) {
const self = this; const self = this;
const force = !!done;
if (!done) { if (!done) {
self.loading = true; self.loading = true;
@@ -601,6 +602,7 @@ export default {
]).then(() => { ]).then(() => {
return self.transactionsStore.loadTransactions({ return self.transactionsStore.loadTransactions({
reload: true, reload: true,
force: force,
autoExpand: true, autoExpand: true,
defaultCurrency: self.defaultCurrency defaultCurrency: self.defaultCurrency
}); });
@@ -609,6 +611,10 @@ export default {
done(); done();
} }
if (force) {
self.$toast('Data has been updated');
}
self.loading = false; self.loading = false;
}).catch(error => { }).catch(error => {
if (error.processed || done) { if (error.processed || done) {
@@ -48,6 +48,7 @@ import { useUserStore } from '@/stores/user.js';
import { useTokensStore } from '@/stores/token.js'; import { useTokensStore } from '@/stores/token.js';
import iconConstants from '@/consts/icon.js'; import iconConstants from '@/consts/icon.js';
import { isEquals } from '@/lib/common.js';
import { parseDeviceInfo, parseUserAgent } from '@/lib/misc.js'; import { parseDeviceInfo, parseUserAgent } from '@/lib/misc.js';
import { onSwipeoutDeleted } from '@/lib/ui.mobile.js'; import { onSwipeoutDeleted } from '@/lib/ui.mobile.js';
@@ -118,6 +119,12 @@ export default {
done(); done();
} }
if (isEquals(self.tokens, tokens)) {
self.$toast('Session list is up to date');
} else {
self.$toast('Session list has been updated');
}
self.tokens = tokens; self.tokens = tokens;
}).catch(error => { }).catch(error => {
if (done) { if (done) {