Skip to content

Commit

Permalink
postpone password setting popup for the onboarding time
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-1979 committed Mar 29, 2024
1 parent eadfee2 commit 32a32be
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
14 changes: 11 additions & 3 deletions packages/extension-polkagate/src/components/Loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const FlyingLogo = ({ theme }: { theme: Theme }) => (
/>
);

export default function Loading({ children }: Props): React.ReactElement<Props> {
export default function Loading ({ children }: Props): React.ReactElement<Props> {
const theme = useTheme();
const manifest = useManifest();
const { isExtensionLocked, setExtensionLock } = useExtensionLockContext();
Expand Down Expand Up @@ -140,7 +140,14 @@ export default function Loading({ children }: Props): React.ReactElement<Props>
const handleInitLoginInfo = async () => {
const info = await getStorage('loginInfo') as LoginInfo;

if (!info?.status || info?.status === 'reset') {
if (!info?.status) {
/** To not asking for password setting for the onboarding time */
setStorage('loginInfo', { lastLoginTime: Date.now(), status: 'mayBeLater' }).catch(console.error);

return setExtensionLock(false);
}

if (info?.status === 'reset') {
return setStep(STEPS.ASK_TO_SET_PASSWORD);
}

Expand Down Expand Up @@ -182,7 +189,8 @@ export default function Loading({ children }: Props): React.ReactElement<Props>
};

handleInitLoginInfo().catch(console.error);
}, [setExtensionLock]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const onPassChange = useCallback((pass: string | null): void => {
if (!pass) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ function AskToSetPassword({ setStep }: Props): React.ReactElement {
const onMayBeLater = useCallback(() => {
setExtensionLock(false);

// eslint-disable-next-line @typescript-eslint/no-floating-promises
setStorage('loginInfo', { lastLoginTime: Date.now(), status: 'mayBeLater' });
setStorage('loginInfo', { lastLoginTime: Date.now(), status: 'mayBeLater' }).catch(console.error);
}, [setExtensionLock]);

const onNoPassword = useCallback(() => {
Expand Down
3 changes: 1 addition & 2 deletions packages/extension-ui/src/Popup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ export default function Popup (): React.ReactElement {
setLoginInfo(info);
};

// eslint-disable-next-line @typescript-eslint/no-floating-promises
fetchLoginInfo();
fetchLoginInfo().catch(console.error);
}, []);

useEffect((): void => {
Expand Down

0 comments on commit 32a32be

Please sign in to comment.