From 69a1884f92bdf834b8dd8b09198a3d9523b0f601 Mon Sep 17 00:00:00 2001 From: Michal Date: Fri, 2 Aug 2024 16:52:02 +0100 Subject: [PATCH] Change browser behaviour --- .../features/Discover/common/BrowserProvider.tsx | 14 +++++++------- packages/dapp-connector/src/manager.mocks.ts | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/wallet-mobile/src/features/Discover/common/BrowserProvider.tsx b/apps/wallet-mobile/src/features/Discover/common/BrowserProvider.tsx index 78502f2280..868a9cd1d1 100644 --- a/apps/wallet-mobile/src/features/Discover/common/BrowserProvider.tsx +++ b/apps/wallet-mobile/src/features/Discover/common/BrowserProvider.tsx @@ -44,28 +44,28 @@ export const BrowserProvider = ({ initialState?: Partial }) => { const { - selected: {wallet}, + selected: {wallet, network}, } = useWalletManager() - const walletId = wallet?.id + const storageId = wallet?.id != null ? `${wallet.id}-${network}` : null const [browserState, dispatch] = React.useReducer(browserReducer, {...defaultState, ...initialState}) React.useEffect(() => { - if (walletId === undefined) return - memoryStorage.set(walletId, browserState) + if (storageId === null) return + memoryStorage.set(storageId, browserState) // eslint-disable-next-line react-hooks/exhaustive-deps }, [browserState]) React.useEffect(() => { - if (walletId === undefined) return - const state = memoryStorage.get(walletId) + if (storageId === null) return + const state = memoryStorage.get(storageId) if (state) { dispatch({type: BrowserActionType.SetState, state}) } else { dispatch({type: BrowserActionType.SetState, state: {...defaultState, ...initialState}}) } - }, [walletId, initialState]) + }, [storageId, initialState]) const actions = React.useRef({ addTab: (url, id) => { diff --git a/packages/dapp-connector/src/manager.mocks.ts b/packages/dapp-connector/src/manager.mocks.ts index c5d2011f8e..0291eca905 100644 --- a/packages/dapp-connector/src/manager.mocks.ts +++ b/packages/dapp-connector/src/manager.mocks.ts @@ -3,6 +3,7 @@ import {DappListResponse} from './adapters/api' export const managerMock: DappConnectorManager = { chainId: 1, + walletId: 'walletId', getDAppList(): Promise { return Promise.resolve(mockedDAppList) },