Skip to content

Commit

Permalink
show whether data is updated after pull down
Browse files Browse the repository at this point in the history
  • Loading branch information
mayswind committed Jun 18, 2023
1 parent 55ad7b2 commit eb2e2b0
Show file tree
Hide file tree
Showing 15 changed files with 102 additions and 17 deletions.
10 changes: 10 additions & 0 deletions src/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 is up to date',
'Data has been updated': 'Data has been updated',
'Net assets': 'Net assets',
'Total assets': 'Total assets',
'Total liabilities': 'Total liabilities',
Expand All @@ -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 is up to date',
'Account list has been updated': 'Account list has been updated',
'No available account': 'No available account',
'Add Account': 'Add Account',
'Edit Account': 'Edit Account',
Expand Down Expand Up @@ -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 is up to date',
'Session list has been updated': 'Session list has been updated',
'Current': 'Current',
'Other Device': 'Other Device',
'Unknown Device': 'Unknown Device',
Expand All @@ -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 is up to date',
'Category list has been updated': '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',
Expand Down Expand Up @@ -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 is up to date',
'Tag list has been updated': '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',
Expand Down
10 changes: 10 additions & 0 deletions src/locales/zh_Hans.js
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,8 @@ export default {
'This Year': '今年',
'Monthly income': '当月收入',
'Unable to get transaction overview': '无法获取交易概要',
'Data is up to date': '数据已是最新',
'Data has been updated': '数据已更新',
'Net assets': '净资产',
'Total assets': '总资产',
'Total liabilities': '总负债',
Expand All @@ -826,6 +828,8 @@ export default {
'Receivables': '应收款项',
'Investment Account': '投资账户',
'Unable to get account list': '无法获取账户列表',
'Account list is up to date': '账户列表已是最新',
'Account list has been updated': '账户列表已更新',
'No available account': '没有可用的账户',
'Add Account': '添加账户',
'Edit Account': '编辑账户',
Expand Down Expand Up @@ -989,6 +993,8 @@ export default {
'Device & Sessions': '设备和会话',
'Logout All': '注销全部',
'Unable to get session list': '无法获取会话列表',
'Session list is up to date': '会话列表已是最新',
'Session list has been updated': '会话列表已更新',
'Current': '当前',
'Other Device': '其他设备',
'Unknown Device': '未知设备',
Expand All @@ -1008,6 +1014,8 @@ export default {
'Add Default Categories': '添加默认分类',
'Default Categories': '默认分类',
'Unable to get category list': '无法获取分类列表',
'Category list is up to date': '分类列表已是最新',
'Category list has been updated': '分类列表已更新',
'Unable to move category': '无法移动分类',
'Unable to hide this category': '无法隐藏该分类',
'Unable to unhide this category': '无法取消隐藏该分类',
Expand Down Expand Up @@ -1035,6 +1043,8 @@ export default {
'Tag Title': '标签标题',
'No available tag': '没有可用的标签',
'Unable to get tag list': '无法获取标签列表',
'Tag list is up to date': '标签列表已是最新',
'Tag list has been updated': '标签列表已更新',
'Unable to add tag': '无法添加标签',
'Unable to save tag': '无法保存标签',
'Unable to move tag': '无法移动标签',
Expand Down
11 changes: 8 additions & 3 deletions src/stores/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/stores/exchangeRates.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
11 changes: 8 additions & 3 deletions src/stores/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => ({
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 8 additions & 2 deletions src/stores/transactionCategory.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 8 additions & 2 deletions src/stores/transactionTag.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 6 additions & 1 deletion src/views/mobile/HomePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,20 @@ export default {
},
reload(done) {
const self = this;
const force = !!done;
self.overviewStore.loadTransactionOverview({
defaultCurrency: self.defaultCurrency,
dateRange: self.dateRange,
force: true
force: force
}).then(() => {
if (done) {
done();
}
if (force) {
self.$toast('Data has been updated');
}
}).catch(error => {
if (done) {
done();
Expand Down
7 changes: 6 additions & 1 deletion src/views/mobile/accounts/ListPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,18 @@ export default {
}
const self = this;
const force = !!done;
self.accountsStore.loadAllAccounts({
force: true
force: force
}).then(() => {
if (done) {
done();
}
if (force) {
self.$toast('Account list has been updated');
}
}).catch(error => {
if (done) {
done();
Expand Down
7 changes: 6 additions & 1 deletion src/views/mobile/categories/AllPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,18 @@ export default {
},
reload(done) {
const self = this;
const force = !!done;
self.transactionCategoriesStore.loadAllCategories({
force: true
force: force
}).then(() => {
if (done) {
done();
}
if (force) {
self.$toast('Category list has been updated');
}
}).catch(error => {
if (done) {
done();
Expand Down
7 changes: 6 additions & 1 deletion src/views/mobile/categories/ListPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,18 @@ export default {
}
const self = this;
const force = !!done;
self.transactionCategoriesStore.loadAllCategories({
force: true
force: force
}).then(() => {
if (done) {
done();
}
if (force) {
self.$toast('Category list has been updated');
}
}).catch(error => {
if (done) {
done();
Expand Down
7 changes: 6 additions & 1 deletion src/views/mobile/statistics/TransactionPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ export default {
},
reload(done) {
const self = this;
const force = !!done;
let dispatchPromise = null;
if (self.query.chartDataType === self.allChartDataTypes.ExpenseByAccount.type ||
Expand All @@ -510,7 +511,7 @@ export default {
} else if (self.query.chartDataType === self.allChartDataTypes.AccountTotalAssets.type ||
self.query.chartDataType === self.allChartDataTypes.AccountTotalLiabilities.type) {
dispatchPromise = self.accountsStore.loadAllAccounts({
force: true
force: force
});
}
Expand All @@ -519,6 +520,10 @@ export default {
if (done) {
done();
}
if (force) {
self.$toast('Data has been updated');
}
}).catch(error => {
if (done) {
done();
Expand Down
7 changes: 6 additions & 1 deletion src/views/mobile/tags/ListPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,18 @@ export default {
}
const self = this;
const force = !!done;
self.transactionTagsStore.loadAllTags({
force: true
force: force
}).then(() => {
if (done) {
done();
}
if (force) {
self.$toast('Tag list has been updated');
}
}).catch(error => {
if (done) {
done();
Expand Down
6 changes: 6 additions & 0 deletions src/views/mobile/transactions/ListPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ export default {
},
reload(done) {
const self = this;
const force = !!done;
if (!done) {
self.loading = true;
Expand All @@ -601,6 +602,7 @@ export default {
]).then(() => {
return self.transactionsStore.loadTransactions({
reload: true,
force: force,
autoExpand: true,
defaultCurrency: self.defaultCurrency
});
Expand All @@ -609,6 +611,10 @@ export default {
done();
}
if (force) {
self.$toast('Data has been updated');
}
self.loading = false;
}).catch(error => {
if (error.processed || done) {
Expand Down
7 changes: 7 additions & 0 deletions src/views/mobile/users/SessionListPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { useUserStore } from '@/stores/user.js';
import { useTokensStore } from '@/stores/token.js';
import iconConstants from '@/consts/icon.js';
import { isEquals } from '@/lib/common.js';
import { parseDeviceInfo, parseUserAgent } from '@/lib/misc.js';
import { onSwipeoutDeleted } from '@/lib/ui.mobile.js';
Expand Down Expand Up @@ -118,6 +119,12 @@ export default {
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;
}).catch(error => {
if (done) {
Expand Down

0 comments on commit eb2e2b0

Please sign in to comment.