Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check the initialization status of the export page button #644

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React, { useCallback, useMemo, useState } from 'react';
import styled, { useTheme } from 'styled-components';

import { Row, View, WebButton, WebImg, WebText } from '@components/atoms';
import { ExportType } from '@hooks/web/wallet-export/use-wallet-export-screen';
import { WebSeedBox } from '@components/molecules';
import { WebPrivateKeyBox } from '@components/molecules/web-private-key-box';
import { AdenaStorage } from '@common/storage';
import IconWarning from '@assets/web/warning.svg';
import { WALLET_EXPORT_TYPE_STORAGE_KEY } from '@common/constants/storage.constant';
import { AdenaStorage } from '@common/storage';
import { Row, View, WebButton, WebImg, WebText } from '@components/atoms';
import { WebCopyButton } from '@components/atoms/web-copy-button';
import { WebHoldButton } from '@components/atoms/web-hold-button';
import { WebSeedBox } from '@components/molecules';
import { WebPrivateKeyBox } from '@components/molecules/web-private-key-box';
import { ExportType } from '@hooks/web/wallet-export/use-wallet-export-screen';
import { getTheme } from '@styles/theme';
import IconWarning from '@assets/web/warning.svg';

const StyledContainer = styled(View)`
width: 100%;
Expand Down Expand Up @@ -47,6 +47,7 @@ interface WalletExportResultProps {
const WalletExportResult: React.FC<WalletExportResultProps> = ({ exportType, exportData }) => {
const theme = useTheme();
const [blur, setBlur] = useState(true);
const [initializedDone, setInitializedDone] = useState(false);

const title = useMemo(() => {
if (exportType === 'PRIVATE_KEY') {
Expand Down Expand Up @@ -76,11 +77,19 @@ const WalletExportResult: React.FC<WalletExportResultProps> = ({ exportType, exp
return exportData;
}, [exportType, exportData]);

const onMouseDownDone = (): void => {
setInitializedDone(true);
};

const onFinishHold = useCallback((finished: boolean) => {
setBlur(!finished);
}, []);

const onClickDone = (): void => {
if (!initializedDone) {
return;
}

AdenaStorage.session()
.remove(WALLET_EXPORT_TYPE_STORAGE_KEY)
.then(() => {
Expand Down Expand Up @@ -111,7 +120,13 @@ const WalletExportResult: React.FC<WalletExportResultProps> = ({ exportType, exp
</Row>
</StyledInputBox>

<WebButton figure='primary' size='full' onClick={onClickDone} text='Done' />
<WebButton
figure='primary'
size='full'
onMouseDown={onMouseDownDone}
onClick={onClickDone}
text='Done'
/>
</StyledContainer>
);
};
Expand Down
Loading