Skip to content

Commit

Permalink
fix(suite): fix cancel button in second step of dry run recovery
Browse files Browse the repository at this point in the history
  • Loading branch information
komret committed Nov 19, 2024
1 parent 126b478 commit 173d770
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/suite/src/views/recovery/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ export const Recovery = ({ onCancel }: ForegroundAppProps) => {
const hasFinished = recovery.status === 'finished';
const hasError = recovery.error !== undefined;

const handleClose = () => {
if (['in-progress', 'waiting-for-confirmation'].includes(recovery.status)) {
TrezorConnect.cancel(intl.formatMessage(messages.TR_CANCELLED));
} else {
onCancel();
}
};

if (!isDeviceAcquired(device) || !deviceModelInternal) {
return (
<NewModal
Expand Down Expand Up @@ -240,19 +248,13 @@ export const Recovery = ({ onCancel }: ForegroundAppProps) => {
)}
<NewModal.Button
variant={hasFinished ? undefined : 'tertiary'}
onClick={() => onCancel()}
onClick={handleClose}
>
<Translation id="TR_CLOSE" />
</NewModal.Button>
</>
}
onCancel={() => {
if (['in-progress', 'waiting-for-confirmation'].includes(recovery.status)) {
TrezorConnect.cancel(intl.formatMessage(messages.TR_CANCELLED));
} else {
onCancel();
}
}}
onCancel={handleClose}
variant={hasFinished && hasError ? 'warning' : 'primary'}
// eslint-disable-next-line no-nested-ternary
iconName={hasFinished ? (hasError ? 'warning' : 'check') : undefined}
Expand Down

0 comments on commit 173d770

Please sign in to comment.