Skip to content

Commit

Permalink
chore: according to review, changed the hard-coded strings to be vari…
Browse files Browse the repository at this point in the history
…ables and changed function goToStep to condier the case -1
  • Loading branch information
AntonioVentilii committed May 24, 2024
1 parent 5d70abe commit 9661e37
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/frontend/src/lib/components/send/QRCodeModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,34 @@
export let steps: WizardSteps;
export let currentStep: WizardStep | undefined = undefined;
const STEP_QRCODE = 'QRCode';
let qrCodeStep = 'Scan QR Code';
let stepsPlusQr: WizardSteps;
$: stepsPlusQr = [
...steps,
{
name: STEP_QRCODE,
name: qrCodeStep,
title: $i18n.send.text.scan_qr
}
];
let modal: WizardModal;
const goToStep = (stepName: string) => {
const stepNumber = stepsPlusQr.findIndex(({ name }) => name === stepName);
const stepNumber = Math.max(
stepsPlusQr.findIndex(({ name }) => name === stepName),
0
);
modal.set(stepNumber);
};
let resolveQrCodePromise:
| (({ status, code }: { status: QrStatus; code?: string }) => void)
| undefined = undefined;
export const scanQrCode = async ({
expectedToken
}: {
expectedToken: Token;
}): Promise<QrResponse> => {
export const scanQrCode = ({ expectedToken }: { expectedToken: Token }): Promise<QrResponse> => {
const prevStep = currentStep;
goToStep(STEP_QRCODE);
goToStep(qrCodeStep);
return new Promise<{ status: QrStatus; code?: string | undefined }>((resolve) => {
resolveQrCodePromise = resolve;
Expand All @@ -52,7 +51,7 @@
toastsError({
msg: { text: $i18n.send.error.incompatible_token }
});
return Promise.reject(new Error('Token incompatible'));
return Promise.reject(new Error($i18n.send.error.incompatible_token));
}
return decodeQrCode({ status, code, expectedToken });
})
Expand All @@ -79,7 +78,7 @@
disablePointerEvents={currentStep?.name === 'Sending'}
>
<svelte:fragment slot="title">{$i18n.send.text.scan_qr}</svelte:fragment>
{#if currentStep?.name === STEP_QRCODE}
{#if currentStep?.name === qrCodeStep}
<QRCodeReaderModal on:nnsCancel={onCancel} on:nnsQRCode={onQRCode} />
{/if}
</WizardModal>

0 comments on commit 9661e37

Please sign in to comment.