diff --git a/packages/shared/lib/wallet.ts b/packages/shared/lib/wallet.ts
index edd3f411811..5bc013ccc7e 100644
--- a/packages/shared/lib/wallet.ts
+++ b/packages/shared/lib/wallet.ts
@@ -4,7 +4,7 @@ import { persistent } from 'shared/lib/helpers'
import { _ } from 'shared/lib/i18n'
import type { HistoryData, PriceData } from 'shared/lib/marketData'
import { HistoryDataProps } from 'shared/lib/marketData'
-import { showSystemNotification } from 'shared/lib/notifications'
+import { showAppNotification, showSystemNotification } from 'shared/lib/notifications'
import { activeProfile, updateProfile } from 'shared/lib/profile'
import { formatUnit } from 'shared/lib/units'
import { get, writable, Writable } from 'svelte/store'
@@ -574,3 +574,27 @@ export const getWalletBalanceHistory = (accountsBalanceHistory: BalanceHistory):
})
return balanceHistory
}
+
+/**
+ * Sync the accounts
+ */
+export function syncAccounts() {
+ isSyncing.set(true)
+ api.syncAccounts({
+ onSuccess(syncAccountsResponse) {
+ const syncedAccounts = syncAccountsResponse.payload
+
+ updateAccounts(syncedAccounts)
+
+ isSyncing.set(false)
+ },
+ onError(err) {
+ isSyncing.set(false)
+ const locale = get(_) as (string) => string
+ showAppNotification({
+ type: 'error',
+ message: locale(err.error),
+ })
+ },
+ })
+}
\ No newline at end of file
diff --git a/packages/shared/routes/dashboard/settings/views/Advanced.svelte b/packages/shared/routes/dashboard/settings/views/Advanced.svelte
index 9396a9d2c88..1cadfc66e37 100644
--- a/packages/shared/routes/dashboard/settings/views/Advanced.svelte
+++ b/packages/shared/routes/dashboard/settings/views/Advanced.svelte
@@ -3,12 +3,12 @@
import { Button, Checkbox, Dropdown, Radio, Text } from 'shared/components'
import { developerMode } from 'shared/lib/app'
import { DEFAULT_NODE, DEFAULT_NODES } from 'shared/lib/network'
+ import { showAppNotification } from 'shared/lib/notifications'
import { openPopup } from 'shared/lib/popup'
import { activeProfile, updateProfile } from 'shared/lib/profile'
import type { Node } from 'shared/lib/typings/client'
- import { api, updateAccounts, wallet, WalletAccount } from 'shared/lib/wallet'
+ import { api, isSyncing, syncAccounts, wallet, WalletAccount } from 'shared/lib/wallet'
import { get } from 'svelte/store'
- import { showAppNotification } from 'shared/lib/notifications'
export let locale
@@ -155,30 +155,6 @@
function handleErrorLogClick() {
openPopup({ type: 'errorLog' })
}
-
- function resyncAccounts() {
- const _sync = () => {
- api.syncAccounts({
- onSuccess(syncAccountsResponse) {
- const syncedAccounts = syncAccountsResponse.payload
-
- updateAccounts(syncedAccounts)
- },
- onError(err) {
- showAppNotification({
- type: 'error',
- message: locale(err.error),
- })
- },
- })
- }
-
- if ($activeProfile.isStrongholdLocked) {
- openPopup({ type: 'password', props: { onSuccess: _sync } })
- } else {
- _sync()
- }
- }
@@ -236,7 +212,7 @@
{locale('views.settings.resyncAccounts.title')}
{locale('views.settings.resyncAccounts.description')}
-
+
diff --git a/packages/shared/routes/dashboard/wallet/Wallet.svelte b/packages/shared/routes/dashboard/wallet/Wallet.svelte
index 427732f4ade..c76ac465dd7 100644
--- a/packages/shared/routes/dashboard/wallet/Wallet.svelte
+++ b/packages/shared/routes/dashboard/wallet/Wallet.svelte
@@ -7,12 +7,12 @@
import { deepLinkRequestActive } from 'shared/lib/deepLinking'
import { priceData } from 'shared/lib/marketData'
import { DEFAULT_NODE, DEFAULT_NODES, network } from 'shared/lib/network'
+ import { showAppNotification } from 'shared/lib/notifications'
import { openPopup } from 'shared/lib/popup'
import { activeProfile, updateProfile } from 'shared/lib/profile'
import { walletRoute } from 'shared/lib/router'
import { WalletRoutes } from 'shared/lib/typings/routes'
import { formatUnit } from 'shared/lib/units'
- import { showAppNotification } from 'shared/lib/notifications'
import {
AccountMessage,
api,
@@ -24,8 +24,8 @@
initialiseListeners,
isTransferring,
selectedAccountId,
+ syncAccounts,
transferState,
- updateAccounts,
updateBalanceOverview,
wallet,
WalletAccount,
@@ -128,32 +128,40 @@
function getAccounts() {
api.getAccounts({
onSuccess(accountsResponse) {
- syncAccounts()
-
- const _totalBalance = {
- balance: 0,
- incoming: 0,
- outgoing: 0,
+ const _continue = () => {
+ accountsLoaded.set(true)
+ syncAccounts()
}
- for (const [idx, storedAccount] of accountsResponse.payload.entries()) {
+ if (accountsResponse.payload.length === 0) {
+ _continue()
+ } else {
+ const totalBalance = {
+ balance: 0,
+ incoming: 0,
+ outgoing: 0,
+ }
+
+ for (const [idx, storedAccount] of accountsResponse.payload.entries()) {
getAccountMeta(storedAccount.id, (err, meta) => {
if (!err) {
- _totalBalance.balance += meta.balance
- _totalBalance.incoming += meta.incoming
- _totalBalance.outgoing += meta.outgoing
+ totalBalance.balance += meta.balance
+ totalBalance.incoming += meta.incoming
+ totalBalance.outgoing += meta.outgoing
const account = prepareAccountInfo(storedAccount, meta)
accounts.update((accounts) => [...accounts, account])
if (idx === accountsResponse.payload.length - 1) {
- updateBalanceOverview(_totalBalance.balance, _totalBalance.incoming, _totalBalance.outgoing)
+ updateBalanceOverview(totalBalance.balance, totalBalance.incoming, totalBalance.outgoing)
+ _continue()
}
} else {
console.error(err)
}
})
}
+ }
},
onError(err) {
showAppNotification({
@@ -213,24 +221,6 @@
})
}
- function syncAccounts() {
- api.syncAccounts({
- onSuccess(syncAccountsResponse) {
- const syncedAccounts = syncAccountsResponse.payload
-
- updateAccounts(syncedAccounts)
-
- accountsLoaded.set(true)
- },
- onError(err) {
- showAppNotification({
- type: 'error',
- message: locale(err.error),
- })
- },
- })
- }
-
function onCreateAccount(alias, completeCallback) {
const _create = () =>
api.createAccount(
@@ -372,8 +362,10 @@
{
messages: [
Object.assign({}, response.payload, {
- incoming: isReceiverAccount
- }), ..._account.messages],
+ incoming: isReceiverAccount,
+ }),
+ ..._account.messages,
+ ],
}
)
}
diff --git a/packages/shared/routes/dashboard/wallet/views/WalletActions.svelte b/packages/shared/routes/dashboard/wallet/views/WalletActions.svelte
index c76808420fd..979ea042aea 100644
--- a/packages/shared/routes/dashboard/wallet/views/WalletActions.svelte
+++ b/packages/shared/routes/dashboard/wallet/views/WalletActions.svelte
@@ -61,26 +61,24 @@
{locale('general.accounts')}
-
- {#if $accountsLoaded}
- {#if $accounts.length > 0}
-
- {#each $accounts as account}
-
= 3 ? 's' : $accounts.length === 2 ? 'm' : 'l'}
- onClick={() => handleAccountClick(account.id)} />
- {/each}
-
- {:else}
-
{locale('general.no_accounts')}
- {/if}
+ {#if $accounts.length > 0}
+
+ {#each $accounts as account}
+
= 3 ? 's' : $accounts.length === 2 ? 'm' : 'l'}
+ onClick={() => handleAccountClick(account.id)} />
+ {/each}
+
+ {:else}
+
{locale('general.no_accounts')}
{/if}
{#if $accounts.length > 0}
diff --git a/packages/shared/routes/dashboard/wallet/views/WalletHistory.svelte b/packages/shared/routes/dashboard/wallet/views/WalletHistory.svelte
index baec61fa0c8..fcbbd8dad5b 100644
--- a/packages/shared/routes/dashboard/wallet/views/WalletHistory.svelte
+++ b/packages/shared/routes/dashboard/wallet/views/WalletHistory.svelte
@@ -1,9 +1,8 @@
-
{locale('general.latest_transactions')}
- {#if $accountsLoaded}
-
- {#if $transactions?.length}
- {#each $transactions as transaction}
-
handleTransactionClick(transaction)}
- color={$accounts.find((acc) => acc.index === transaction.account)?.color} />
- {/each}
- {:else}
-
- {locale('general.no_recent_history')}
-
- {/if}
-
- {/if}
+
+ {locale('general.latest_transactions')}
+
+
+
+
+
+ {#if $transactions?.length}
+ {#each $transactions as transaction}
+
handleTransactionClick(transaction)}
+ color={$accounts.find((acc) => acc.index === transaction.account)?.color} />
+ {/each}
+ {:else}
+
+ {locale('general.no_recent_history')}
+
+ {/if}
+