Skip to content

Commit

Permalink
close onboarding opened tabs on cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-1979 committed Apr 21, 2024
1 parent 0bcc702 commit 6cd5e7a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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), []);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Grid bgcolor='backgroundFL.primary' container item justifyContent='center'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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<ResponseJsonGetAccountInfo[]>([]);
Expand Down Expand Up @@ -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);
Expand All @@ -118,7 +118,7 @@ export default function RestoreJson (): React.ReactElement {
setPassword('');
}, []);

const onCancel = useCallback(() => onAction('/'), [onAction]);
const onCancel = useCallback(() => window.close(), []);

return (
<Grid bgcolor='backgroundFL.primary' container item justifyContent='center'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ function CreateAccount (): React.ReactElement {
}
}, [name, onAction, password, seed]);

const onCancel = useCallback(() => {
onAction('/');
}, [onAction]);
const onCancel = useCallback(() => window.close(), []);

return (
<Grid bgcolor='backgroundFL.primary' container item justifyContent='center'>
Expand Down

0 comments on commit 6cd5e7a

Please sign in to comment.