From 6cd5e7a9a77a0467a5726f62a4ef88c5e0576d5c Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 22 Apr 2024 02:41:22 +0330 Subject: [PATCH] close onboarding opened tabs on cancel --- .../src/popup/import/addWatchOnlyFullScreen/index.tsx | 2 +- .../src/popup/import/importLedger/index.tsx | 2 +- .../src/popup/import/importSeedFullScreen/index.tsx | 2 +- .../src/popup/import/restoreJSONFullScreen/index.tsx | 8 ++++---- .../popup/newAccount/createAccountFullScreen/index.tsx | 4 +--- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/extension-polkagate/src/popup/import/addWatchOnlyFullScreen/index.tsx b/packages/extension-polkagate/src/popup/import/addWatchOnlyFullScreen/index.tsx index 835f210ce..9c8b3763b 100644 --- a/packages/extension-polkagate/src/popup/import/addWatchOnlyFullScreen/index.tsx +++ b/packages/extension-polkagate/src/popup/import/addWatchOnlyFullScreen/index.tsx @@ -76,7 +76,7 @@ export default function AddWatchOnlyFullScreen (): React.ReactElement { } }, [chain?.genesisHash, name, onAction, realAddress]); - const onCancel = useCallback(() => onAction('/'), [onAction]); + const onCancel = useCallback(() => window.close(), []); const onNameChange = useCallback((name: string | null) => setName(name), []); diff --git a/packages/extension-polkagate/src/popup/import/importLedger/index.tsx b/packages/extension-polkagate/src/popup/import/importLedger/index.tsx index 165c89a70..766d3c652 100644 --- a/packages/extension-polkagate/src/popup/import/importLedger/index.tsx +++ b/packages/extension-polkagate/src/popup/import/importLedger/index.tsx @@ -133,7 +133,7 @@ export default function ImportLedger (): React.ReactElement { !accounts.length && onAction(); }, [accounts, onAction]); - const onCancel = useCallback(() => onAction('/'), [onAction]); + const onCancel = useCallback(() => window.close(), []); return ( diff --git a/packages/extension-polkagate/src/popup/import/importSeedFullScreen/index.tsx b/packages/extension-polkagate/src/popup/import/importSeedFullScreen/index.tsx index d3f7f8583..458ed5d87 100644 --- a/packages/extension-polkagate/src/popup/import/importSeedFullScreen/index.tsx +++ b/packages/extension-polkagate/src/popup/import/importSeedFullScreen/index.tsx @@ -131,7 +131,7 @@ export default function ImportSeed (): React.ReactElement { setPassword(pass); }, []); - const onCancel = useCallback(() => onAction('/'), [onAction]); + const onCancel = useCallback(() => window.close(), []); const toggleMore = useCallback(() => setShowMore(!showMore), [showMore]); return ( diff --git a/packages/extension-polkagate/src/popup/import/restoreJSONFullScreen/index.tsx b/packages/extension-polkagate/src/popup/import/restoreJSONFullScreen/index.tsx index 9c0448962..6f61fec1a 100644 --- a/packages/extension-polkagate/src/popup/import/restoreJSONFullScreen/index.tsx +++ b/packages/extension-polkagate/src/popup/import/restoreJSONFullScreen/index.tsx @@ -12,6 +12,7 @@ import type { KeyringPairs$Json } from '@polkadot/ui-keyring/types'; import { Grid, Typography, useTheme } from '@mui/material'; import React, { useCallback, useContext, useState } from 'react'; +import { openOrFocusTab } from '@polkadot/extension-polkagate/src/fullscreen/accountDetails/components/CommonTasks'; import { FULLSCREEN_WIDTH } from '@polkadot/extension-polkagate/src/util/constants'; import { u8aToString } from '@polkadot/util'; @@ -30,7 +31,6 @@ export default function RestoreJson (): React.ReactElement { useFullscreen(); const { t } = useTranslation(); const theme = useTheme(); - const onAction = useContext(ActionContext); const [isBusy, setIsBusy] = useState(false); const [stepOne, setStep] = useState(true); const [accountsInfo, setAccountsInfo] = useState([]); @@ -102,14 +102,14 @@ export default function RestoreJson (): React.ReactElement { (isKeyringPairs$Json(file) ? batchRestore(file, password) : jsonRestore(file, password)) .then(() => { - onAction('/'); + openOrFocusTab('/', true); }) .catch((e) => { console.error(e); setIsBusy(false); setIsPasswordError(true); }); - }, [file, onAction, password, requirePassword]); + }, [file, password, requirePassword]); const onBack = useCallback(() => { setFile(undefined); @@ -118,7 +118,7 @@ export default function RestoreJson (): React.ReactElement { setPassword(''); }, []); - const onCancel = useCallback(() => onAction('/'), [onAction]); + const onCancel = useCallback(() => window.close(), []); return ( diff --git a/packages/extension-polkagate/src/popup/newAccount/createAccountFullScreen/index.tsx b/packages/extension-polkagate/src/popup/newAccount/createAccountFullScreen/index.tsx index 56aa65bfa..091b2f854 100644 --- a/packages/extension-polkagate/src/popup/newAccount/createAccountFullScreen/index.tsx +++ b/packages/extension-polkagate/src/popup/newAccount/createAccountFullScreen/index.tsx @@ -96,9 +96,7 @@ function CreateAccount (): React.ReactElement { } }, [name, onAction, password, seed]); - const onCancel = useCallback(() => { - onAction('/'); - }, [onAction]); + const onCancel = useCallback(() => window.close(), []); return (