diff --git a/packages/desktop/components/popups/BalanceFinderPopup.svelte b/packages/desktop/components/popups/BalanceFinderPopup.svelte index 4b0e8f439a9..506d0658964 100644 --- a/packages/desktop/components/popups/BalanceFinderPopup.svelte +++ b/packages/desktop/components/popups/BalanceFinderPopup.svelte @@ -3,7 +3,7 @@ import { Icon as IconEnum } from '@auxiliary/icon' import { showAppNotification } from '@auxiliary/notification' import { PopupId, closePopup, openPopup } from '@auxiliary/popup' - import { findBalances, sumBalanceForAccounts, SearchAlgorithmType } from '@core/account' + import { findBalances, sumBalanceForAccounts, SearchAlgorithmType, selectedAccountIndex } from '@core/account' import { localize } from '@core/i18n' import { displayNotificationForLedgerProfile, ledgerNanoStatus } from '@core/ledger' import { NetworkId } from '@core/network' @@ -21,7 +21,18 @@ generateAndStoreActivitiesForAllAccounts, refreshAccountAssetsForActiveProfile, } from '@core/wallet' - import { Button, FontWeight, KeyValueBox, Text, TextHint, TextType, Icon, Tile, Spinner } from 'shared/components' + import { + Button, + FontWeight, + KeyValueBox, + Text, + TextHint, + TextType, + Icon, + Tile, + Spinner, + Checkbox, + } from 'shared/components' import { TextHintVariant } from 'shared/components/enums' import { onDestroy } from 'svelte' import VirtualList from '@sveltejs/svelte-virtual-list' @@ -33,20 +44,29 @@ export let consolidateAccountsOnLoad = false export let title: string export let body: string - - const { isStrongholdLocked, network } = $activeProfile - const searchAlgorithm: SearchAlgorithmType = - network.id === NetworkId.Iota || NetworkId.IotaAlphanet ? SearchAlgorithmType.IDS : SearchAlgorithmType.BFS + export let searchInCurrentWallet: boolean = false + export let shouldInitSearch: boolean = false let error = '' let isBusy = false + const { isStrongholdLocked, network } = $activeProfile + $: isTransferring = $visibleActiveAccounts.some( (account) => account.hasConsolidatingOutputsTransactionInProgress || account.isTransferring ) + $: visibleWalletList = searchInCurrentWallet + ? $visibleActiveAccounts?.filter((account) => account.index === $selectedAccountIndex) + : $visibleActiveAccounts $: searchForBalancesOnLoad && !$isStrongholdLocked && onFindBalancesClick() $: consolidateAccountsOnLoad && !$isStrongholdLocked && onConsolidateAccountsClick() $: totalBalance = sumBalanceForAccounts($visibleActiveAccounts) + $: searchInCurrentWallet, (shouldInitSearch = true) + $: searchAlgorithm = searchInCurrentWallet + ? SearchAlgorithmType.DFS + : network.id === NetworkId.Iota || NetworkId.IotaAlphanet + ? SearchAlgorithmType.IDS + : SearchAlgorithmType.BFS // Button click handlers async function onFindBalancesClick(): Promise { @@ -73,9 +93,10 @@ // Actions async function findProfileBalances(): Promise { - await findBalances(searchAlgorithm, !hasUsedBalanceFinder) + await findBalances(searchAlgorithm, !hasUsedBalanceFinder || shouldInitSearch) await loadAccounts() hasUsedBalanceFinder = true + shouldInitSearch = false } async function consolidateProfileAccounts(): Promise { @@ -127,13 +148,22 @@ hasUsedBalanceFinder, title, body, + searchInCurrentWallet, + shouldInitSearch, }, }) }, onCancelled: function () { openPopup({ id: PopupId.BalanceFinder, - props: { hasUsedBalanceFinder, title, body, showConsolidation }, + props: { + hasUsedBalanceFinder, + title, + body, + showConsolidation, + searchInCurrentWallet, + shouldInitSearch, + }, }) }, }, @@ -156,7 +186,7 @@ {body}
- +
@@ -172,11 +202,19 @@
- + {#if !searchInCurrentWallet} + + {/if}
+ (searchInCurrentWallet = !searchInCurrentWallet)} + disabled={isBusy} + /> {#if hasUsedBalanceFinder} - import { Button, Text, ButtonSize } from 'shared/components' + import { Button, Text, ButtonSize, TextType } from 'shared/components' import { localize } from '@core/i18n' import { openPopup, PopupId } from '@auxiliary/popup' @@ -14,8 +14,8 @@ } -{localize('views.settings.balanceFinder.title')} -{localize('views.settings.balanceFinder.description')} +{localize('views.settings.balanceFinder.title')} +{localize('views.settings.balanceFinder.description')}