Skip to content

Commit

Permalink
fix: null account syncing queue store
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwellmattryan committed Jul 28, 2022
1 parent e655826 commit 58233b2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 6 additions & 1 deletion packages/shared/components/modals/AccountSwitcher.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { getAccountColor } from '@lib/profile'
import { WalletAccount } from '@lib/typings/wallet'
import {
accountSyncingQueueStore,
isTransferring,
selectedAccountStore,
setSelectedAccount,
Expand All @@ -28,7 +29,11 @@
showWarning(localize('notifications.participating'))
} else {
setSelectedAccount(accountId)
updateAccountSyncingQueue($selectedAccountStore)
if ($accountSyncingQueueStore?.length > 1) {
updateAccountSyncingQueue($selectedAccountStore)
}
resetAccountRouter(false)
}
modal?.close()
Expand Down
9 changes: 5 additions & 4 deletions packages/shared/lib/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,11 @@ export function initializeAccountSyncingQueue(): void {
}

export function updateAccountSyncingQueue(account: WalletAccount): void {
if (!account) return
const accountSyncingQueue = get(accountSyncingQueueStore)
if (!account || !accountSyncingQueue) return

// It can be assumed that if the account is not currently in the queue then it has already been synced.
const isAccountInSyncingQueue = get(accountSyncingQueueStore).some((_account) => _account.id === account.id)
const isAccountInSyncingQueue = accountSyncingQueue?.some((_account) => _account.id === account.id)
if (!isAccountInSyncingQueue) return

// If the account is already first in the queue then no need to update the queue.
Expand Down Expand Up @@ -1424,11 +1425,11 @@ const calculateInitialAccountSyncOptions = (setupType: SetupType): AccountSyncOp
case SetupType.Mnemonic:
case SetupType.Stronghold:
gapLimit = 25
accountDiscoveryThreshold = 1
accountDiscoveryThreshold = 2
break
case SetupType.FireflyLedger:
gapLimit = 10
accountDiscoveryThreshold = 1
accountDiscoveryThreshold = 2
break
}

Expand Down

0 comments on commit 58233b2

Please sign in to comment.