From 265481146e7b5d9bbb43db66260b44c27a49ff16 Mon Sep 17 00:00:00 2001 From: Charlie Varley Date: Sun, 21 Mar 2021 18:05:47 +0000 Subject: [PATCH] fix: ensure wallet route resets correctly --- packages/shared/components/Sidebar.svelte | 10 +++------- packages/shared/lib/router.ts | 8 ++++++++ packages/shared/routes/dashboard/wallet/Wallet.svelte | 6 +++--- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/shared/components/Sidebar.svelte b/packages/shared/components/Sidebar.svelte index fa13abdb82c..7db695561c7 100644 --- a/packages/shared/components/Sidebar.svelte +++ b/packages/shared/components/Sidebar.svelte @@ -3,9 +3,8 @@ import { getInitials } from 'shared/lib/helpers' import { networkStatus } from 'shared/lib/networkStatus' import { activeProfile } from 'shared/lib/profile' - import { accountRoute, dashboardRoute, settingsRoute, walletRoute } from 'shared/lib/router' - import { AccountRoutes, SettingsRoutes, WalletRoutes, Tabs } from 'shared/lib/typings/routes' - import { selectedAccountId } from 'shared/lib/wallet' + import { dashboardRoute, settingsRoute, resetWalletRoute } from 'shared/lib/router' + import { SettingsRoutes, Tabs } from 'shared/lib/typings/routes' import { onDestroy } from 'svelte' import { get } from 'svelte/store' @@ -38,10 +37,7 @@ } function openWallet() { - dashboardRoute.set(Tabs.Wallet) - walletRoute.set(WalletRoutes.Init) - accountRoute.set(AccountRoutes.Init) - selectedAccountId.set(null) + resetWalletRoute() } diff --git a/packages/shared/lib/router.ts b/packages/shared/lib/router.ts index 6f90260ee49..c2620dce107 100644 --- a/packages/shared/lib/router.ts +++ b/packages/shared/lib/router.ts @@ -1,5 +1,6 @@ import { cleanupSignup, login, strongholdPassword, walletPin } from 'shared/lib/app' import { profiles } from 'shared/lib/profile' +import { selectedAccountId } from 'shared/lib/wallet' import { AccountRoutes, AppRoute, SettingsRoutes, SetupType, Tabs, WalletRoutes } from 'shared/lib/typings/routes' import { get, readable, writable } from 'svelte/store' import { deepLinkRequestActive } from './deepLinking' @@ -225,3 +226,10 @@ export const resetRouter = () => { dashboardRoute.set(Tabs.Wallet) deepLinkRequestActive.set(false) } + +export const resetWalletRoute = () => { + dashboardRoute.set(Tabs.Wallet) + walletRoute.set(WalletRoutes.Init) + accountRoute.set(AccountRoutes.Init) + selectedAccountId.set(null) +} \ No newline at end of file diff --git a/packages/shared/routes/dashboard/wallet/Wallet.svelte b/packages/shared/routes/dashboard/wallet/Wallet.svelte index dd73bb26873..3b21b66d2b8 100644 --- a/packages/shared/routes/dashboard/wallet/Wallet.svelte +++ b/packages/shared/routes/dashboard/wallet/Wallet.svelte @@ -8,7 +8,7 @@ import { showAppNotification } from 'shared/lib/notifications' import { openPopup } from 'shared/lib/popup' import { activeProfile, isStrongholdLocked } from 'shared/lib/profile' - import { walletRoute } from 'shared/lib/router' + import { walletRoute, resetWalletRoute } from 'shared/lib/router' import { WalletRoutes } from 'shared/lib/typings/routes' import { AccountMessage, @@ -246,7 +246,7 @@ setTimeout(() => { sendParams.set({ address: '', amount: 0, message: '' }) isTransferring.set(false) - walletRoute.set(WalletRoutes.Init) + resetWalletRoute() }, 3000) }, onError(err) { @@ -315,7 +315,7 @@ setTimeout(() => { sendParams.set({ address: '', amount: 0, message: '' }) isTransferring.set(false) - walletRoute.set(WalletRoutes.Init) + resetWalletRoute() }, 3000) }, onError(err) {