diff --git a/packages/desktop/components/AccountManagementDetails.svelte b/packages/desktop/components/AccountManagementDetails.svelte index 8b47442ab3b..6ba3ac9d36f 100644 --- a/packages/desktop/components/AccountManagementDetails.svelte +++ b/packages/desktop/components/AccountManagementDetails.svelte @@ -67,7 +67,14 @@ $: hasMainAccountNegativeBIC = hasWalletMainAccountNegativeBIC($selectedWallet) $: hasAccountNegativeBIC = $selectedWallet?.balances?.blockIssuanceCredits?.[(selectedOutput.output as AccountOutput)?.accountId] < 0 - $: selectedOutputPassiveMana = getPassiveManaForOutput(selectedOutput) + + let selectedOutputPassiveMana: number + $: $selectedWallet, (selectedOutputPassiveMana = getPassiveManaForOutput(selectedOutput)) + + $: formattedManaBalance = selectedOutputPassiveMana + ? formatTokenAmountBestMatch(Number(selectedOutputPassiveMana), DEFAULT_MANA) + : '-' + function getImplicitAccountBalance(outputData: OutputData): number | undefined { return Number(outputData.output.amount) } @@ -219,7 +226,7 @@
- {formatTokenAmountBestMatch(selectedOutputPassiveMana, DEFAULT_MANA)} {localize('views.accountManagement.details.mana')} { syncBalancePoll($selectedWalletId, true) + syncNodeInfoPoll() Platform.onEvent('menu-logout', () => { void logout() }) @@ -140,6 +143,7 @@ onDestroy(() => { clearBalanceSyncPoll() + clearNodeInfoSyncPoll() Platform.DeepLinkManager.clearDeepLinkRequest() Platform.removeListenersForEvent('deep-link-params') diff --git a/packages/shared/lib/core/wallet/actions/index.ts b/packages/shared/lib/core/wallet/actions/index.ts index 6a099e258c7..38b2d186342 100644 --- a/packages/shared/lib/core/wallet/actions/index.ts +++ b/packages/shared/lib/core/wallet/actions/index.ts @@ -42,3 +42,4 @@ export * from './prepareMintNft' export * from './prepareCreateNativeToken' export * from './getNetworkMetrics' export * from './getTotalWalletBalance' +export * from './syncNodeInfoPoll' diff --git a/packages/shared/lib/core/wallet/actions/syncNodeInfoPoll.ts b/packages/shared/lib/core/wallet/actions/syncNodeInfoPoll.ts new file mode 100644 index 00000000000..5525b83a37c --- /dev/null +++ b/packages/shared/lib/core/wallet/actions/syncNodeInfoPoll.ts @@ -0,0 +1,15 @@ +import { DEFAULT_SECONDS_PER_SLOT, getAndUpdateNodeInfo } from '../../network' +import { MILLISECONDS_PER_SECOND } from '../../utils' + +let nodeSyncInterval: number + +export async function syncNodeInfoPoll(): Promise { + await getAndUpdateNodeInfo() + nodeSyncInterval = window.setInterval(() => { + void getAndUpdateNodeInfo() + }, DEFAULT_SECONDS_PER_SLOT * MILLISECONDS_PER_SECOND) +} + +export function clearNodeInfoSyncPoll(): void { + clearInterval(nodeSyncInterval) +}