diff --git a/src/stores/account.ts b/src/stores/account.ts index 7af9fc47..c5005891 100644 --- a/src/stores/account.ts +++ b/src/stores/account.ts @@ -29,6 +29,86 @@ export const useAccountsStore = defineStore('accounts', () => { const allCategorizedAccountsMap = ref>({}); const accountListStateInvalid = ref(true); + const allPlainAccounts = computed(() => { + const allAccountsList = []; + + for (let i = 0; i < allAccounts.value.length; i++) { + const account = allAccounts.value[i]; + + if (account.type === AccountType.SingleAccount.type) { + allAccountsList.push(account); + } else if (account.type === AccountType.MultiSubAccounts.type) { + if (account.childrenAccounts) { + for (let j = 0; j < account.childrenAccounts.length; j++) { + const subAccount = account.childrenAccounts[j]; + allAccountsList.push(subAccount); + } + } + } + } + + return allAccountsList; + }); + + const allVisiblePlainAccounts = computed(() => { + const allVisibleAccounts = []; + + for (let i = 0; i < allAccounts.value.length; i++) { + const account = allAccounts.value[i]; + + if (account.hidden) { + continue; + } + + if (account.type === AccountType.SingleAccount.type) { + allVisibleAccounts.push(account); + } else if (account.type === AccountType.MultiSubAccounts.type) { + if (account.childrenAccounts) { + for (let j = 0; j < account.childrenAccounts.length; j++) { + const subAccount = account.childrenAccounts[j]; + allVisibleAccounts.push(subAccount); + } + } + } + } + + return allVisibleAccounts; + }); + + const allAvailableAccountsCount = computed(() => { + let allAccountCount = 0; + + for (const category in allCategorizedAccountsMap.value) { + if (!Object.prototype.hasOwnProperty.call(allCategorizedAccountsMap.value, category)) { + continue; + } + + allAccountCount += allCategorizedAccountsMap.value[category].accounts.length; + } + + return allAccountCount; + }); + + const allVisibleAccountsCount = computed(() => { + let shownAccountCount = 0; + + for (const category in allCategorizedAccountsMap.value) { + if (!Object.prototype.hasOwnProperty.call(allCategorizedAccountsMap.value, category)) { + continue; + } + + const accountList = allCategorizedAccountsMap.value[category].accounts; + + for (let i = 0; i < accountList.length; i++) { + if (!accountList[i].hidden) { + shownAccountCount++; + } + } + } + + return shownAccountCount; + }); + function loadAccountList(accounts: Account[]): void { allAccounts.value = accounts; allAccountsMap.value = {}; @@ -187,86 +267,6 @@ export const useAccountsStore = defineStore('accounts', () => { } } - const allPlainAccounts = computed(() => { - const allAccountsList = []; - - for (let i = 0; i < allAccounts.value.length; i++) { - const account = allAccounts.value[i]; - - if (account.type === AccountType.SingleAccount.type) { - allAccountsList.push(account); - } else if (account.type === AccountType.MultiSubAccounts.type) { - if (account.childrenAccounts) { - for (let j = 0; j < account.childrenAccounts.length; j++) { - const subAccount = account.childrenAccounts[j]; - allAccountsList.push(subAccount); - } - } - } - } - - return allAccountsList; - }); - - const allVisiblePlainAccounts = computed(() => { - const allVisibleAccounts = []; - - for (let i = 0; i < allAccounts.value.length; i++) { - const account = allAccounts.value[i]; - - if (account.hidden) { - continue; - } - - if (account.type === AccountType.SingleAccount.type) { - allVisibleAccounts.push(account); - } else if (account.type === AccountType.MultiSubAccounts.type) { - if (account.childrenAccounts) { - for (let j = 0; j < account.childrenAccounts.length; j++) { - const subAccount = account.childrenAccounts[j]; - allVisibleAccounts.push(subAccount); - } - } - } - } - - return allVisibleAccounts; - }); - - const allAvailableAccountsCount = computed(() => { - let allAccountCount = 0; - - for (const category in allCategorizedAccountsMap.value) { - if (!Object.prototype.hasOwnProperty.call(allCategorizedAccountsMap.value, category)) { - continue; - } - - allAccountCount += allCategorizedAccountsMap.value[category].accounts.length; - } - - return allAccountCount; - }); - - const allVisibleAccountsCount = computed(() => { - let shownAccountCount = 0; - - for (const category in allCategorizedAccountsMap.value) { - if (!Object.prototype.hasOwnProperty.call(allCategorizedAccountsMap.value, category)) { - continue; - } - - const accountList = allCategorizedAccountsMap.value[category].accounts; - - for (let i = 0; i < accountList.length; i++) { - if (!accountList[i].hidden) { - shownAccountCount++; - } - } - } - - return shownAccountCount; - }); - function updateAccountListInvalidState(invalidState: boolean): void { accountListStateInvalid.value = invalidState; }