Skip to content

Commit

Permalink
code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mayswind committed Dec 18, 2024
1 parent c2b1adf commit 50a2221
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 32 deletions.
6 changes: 6 additions & 0 deletions src/stores/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,7 @@ export const useTransactionsStore = defineStore('transactions', {
}
},
updateTransactionListFilter(filter) {
const accountsStore = useAccountsStore();
let changed = false;

if (filter && isNumber(filter.dateType) && this.transactionsFilter.dateType !== filter.dateType) {
Expand Down Expand Up @@ -775,6 +776,11 @@ export const useTransactionsStore = defineStore('transactions', {

if (filter && isString(filter.accountIds) && this.transactionsFilter.accountIds !== filter.accountIds) {
this.transactionsFilter.accountIds = filter.accountIds;

if (datetimeConstants.allBillingCycleDateRangesMap[this.transactionsFilter.dateType] && !accountsStore.getAccountStatementDate(this.transactionsFilter.accountIds)) {
this.transactionsFilter.dateType = datetimeConstants.allDateRanges.Custom.type;
}

changed = true;
}

Expand Down
10 changes: 2 additions & 8 deletions src/views/desktop/common/cards/AccountFilterSettingsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -323,15 +323,9 @@ export default {
self.statisticsStore.updateTransactionStatisticsInvalidState(true);
}
} else if (this.type === 'transactionListCurrent') {
const filter = {
changed = self.transactionsStore.updateTransactionListFilter({
accountIds: isAllSelected ? '' : finalAccountIds
};
if (datetimeConstants.allBillingCycleDateRangesMap[self.transactionsStore.transactionsFilter.dateType] && !self.accountsStore.getAccountStatementDate(filter.accountIds)) {
filter.dateType = datetimeConstants.allDateRanges.Custom.type;
}
changed = self.transactionsStore.updateTransactionListFilter(filter);
});
if (changed) {
self.transactionsStore.updateTransactionListInvalidState(true);
Expand Down
10 changes: 2 additions & 8 deletions src/views/desktop/transactions/ListPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1432,15 +1432,9 @@ export default {
return;
}
const filter = {
const changed = this.transactionsStore.updateTransactionListFilter({
accountIds: accountIds
};
if (datetimeConstants.allBillingCycleDateRangesMap[this.query.dateType] && !this.accountsStore.getAccountStatementDate(accountIds)) {
filter.dateType = datetimeConstants.allDateRanges.Custom.type;
}
const changed = this.transactionsStore.updateTransactionListFilter(filter);
});
if (changed) {
this.loading = true;
Expand Down
10 changes: 2 additions & 8 deletions src/views/mobile/settings/AccountFilterSettingsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,9 @@ export default {
filterAccountIds: filteredAccountIds
});
} else if (this.type === 'transactionListCurrent') {
const filter = {
const changed = self.transactionsStore.updateTransactionListFilter({
accountIds: isAllSelected ? '' : finalAccountIds
};
if (datetimeConstants.allBillingCycleDateRangesMap[self.transactionsStore.transactionsFilter.dateType] && !self.accountsStore.getAccountStatementDate(filter.accountIds)) {
filter.dateType = datetimeConstants.allDateRanges.Custom.type;
}
const changed = self.transactionsStore.updateTransactionListFilter(filter);
});
if (changed) {
self.transactionsStore.updateTransactionListInvalidState(true);
Expand Down
10 changes: 2 additions & 8 deletions src/views/mobile/transactions/ListPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -981,15 +981,9 @@ export default {
return;
}
const filter = {
const changed = this.transactionsStore.updateTransactionListFilter({
accountIds: accountIds
};
if (datetimeConstants.allBillingCycleDateRangesMap[this.query.dateType] && !this.accountsStore.getAccountStatementDate(accountIds)) {
filter.dateType = datetimeConstants.allDateRanges.Custom.type;
}
const changed = this.transactionsStore.updateTransactionListFilter(filter);
});
this.showAccountPopover = false;
Expand Down

0 comments on commit 50a2221

Please sign in to comment.