Skip to content

Commit

Permalink
ui: show account balances table on sync accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
nicole-obrien committed May 14, 2024
1 parent 3bbfd1c commit 2366947
Showing 1 changed file with 29 additions and 28 deletions.
57 changes: 29 additions & 28 deletions packages/desktop/components/popup/popups/SyncAccountsPopup.svelte
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
<script lang="ts">
import { showNotification } from '@auxiliary/notification'
import { Alert, Table, Text, Toggle } from '@bloomwalletio/ui'
import { sumBalanceForAccounts } from '@core/account'
import { Alert, Indicator, Text, Toggle } from '@bloomwalletio/ui'
import { DEFAULT_SYNC_OPTIONS } from '@core/account/constants'
import { selectedAccountIndex } from '@core/account/stores'
import { generateAndStoreActivitiesForAllAccounts } from '@core/activity/actions'
import { localize } from '@core/i18n'
import { ledgerRaceConditionProtectionWrapper } from '@core/ledger'
import { SupportedStardustNetworkId } from '@core/network/constants'
import { StardustNetworkId } from '@core/network/types'
import { loadNftsForActiveProfile } from '@core/nfts/actions'
import { DEFAULT_ACCOUNT_RECOVERY_CONFIGURATION } from '@core/profile'
import { RecoverAccountsPayload, recoverAccounts } from '@core/profile-manager'
import { checkActiveProfileAuth, getBaseToken, loadAccounts } from '@core/profile/actions'
import { checkActiveProfileAuth, loadAccounts } from '@core/profile/actions'
import { activeAccounts, activeProfile, getActiveProfileId, visibleActiveAccounts } from '@core/profile/stores'
import { formatTokenAmount } from '@core/token'
import { loadTokensForAllAccountBalances } from '@core/token/actions'
import { allAccountTokens } from '@core/token/stores'
import { closePopup } from '@desktop/auxiliary/popup'
import { onDestroy } from 'svelte'
import PopupTemplate from '../PopupTemplate.svelte'
import { SupportedStardustNetworkId } from '@core/network/constants'
import { ledgerRaceConditionProtectionWrapper } from '@core/ledger'
import { StardustNetworkId } from '@core/network/types'
import { selectedAccountIndex } from '@core/account/stores'
const { network, type } = $activeProfile
const DEFAULT_CONFIG = DEFAULT_ACCOUNT_RECOVERY_CONFIGURATION[type]
let accountStartIndex = 0
let accountGapLimit = DEFAULT_CONFIG.initialAccountRange
let previousAccountGapLimit = 0
let addressStartIndex = 0
const addressGapLimit = DEFAULT_CONFIG.addressGapLimit
Expand All @@ -37,8 +36,6 @@
let previousAccountsLength = 0
$: totalBalance = sumBalanceForAccounts($visibleActiveAccounts)
const networkSearchMethod: { [key in StardustNetworkId]?: () => Promise<void> } = {
[SupportedStardustNetworkId.Iota]: multiAddressSearch,
[SupportedStardustNetworkId.Shimmer]: singleAddressSearch,
Expand Down Expand Up @@ -126,7 +123,6 @@
await ledgerRaceConditionProtectionWrapper(_function)
await loadAccounts()
previousAccountsLength = $visibleActiveAccounts.length
previousAccountGapLimit = accountGapLimit
hasUsedWalletFinder = true
} catch (err) {
error = localize(err.error)
Expand Down Expand Up @@ -166,7 +162,7 @@
onClick: onFindBalancesClick,
}}
>
<div class="space-y-5">
<div class="flex flex-col overflow-hidden gap-5">
{#if network?.id === SupportedStardustNetworkId.Iota}
<div class="flex gap-2">
<Toggle
Expand All @@ -176,24 +172,29 @@
<Text>{localize('popups.walletFinder.singleAccountSearch')}</Text>
</div>
{/if}
<Table
items={[
{
key: localize('popups.walletFinder.accountsSearched'),
value: previousAccountGapLimit.toString() || '-',
},
{
key: localize('popups.walletFinder.accountsFound'),
value: $activeAccounts.length.toString() || '0',
},
{
key: localize('popups.walletFinder.totalWalletBalance'),
value: formatTokenAmount(totalBalance, getBaseToken()),
},
]}
/>
<account-balance-list class="overflow-y-scroll h-0 flex-1 flex flex-col">
{#each $activeAccounts as account}
{@const baseCoin = $allAccountTokens[account.index]?.[network.id]?.baseCoin}
<div class="w-full flex flex-row items-center justify-between items-center justify-between p-4 gap-3">
<div class="flex flex-row items-center gap-3">
<Indicator color={account.color} />
<Text>{account.name}</Text>
</div>
<Text>{formatTokenAmount(baseCoin?.balance?.total, baseCoin?.metadata)}</Text>
</div>
{/each}
</account-balance-list>
{#if hasUsedWalletFinder}
<Alert variant="info" text={localize('popups.walletFinder.searchAgainHint')} />
{/if}
</div>
</PopupTemplate>

<style lang="postcss">
account-balance-list {
@apply bg-surface-0 dark:bg-surface-0-dark;
@apply border border-solid border-stroke dark:border-stroke-dark;
@apply divide-y divide-solid divide-stroke dark:divide-stroke-dark;
@apply rounded-xl;
}
</style>

0 comments on commit 2366947

Please sign in to comment.