Skip to content

Commit c1c6cb2

Browse files
committed
frontend: rename internal state used for setup choices
A small left over from earlier refactorings, this component ended up with state and appState. Where as appState is the setup choice the user picked. Changed to a more descriptive name for this state.
1 parent ca715cf commit c1c6cb2

File tree

1 file changed

+11
-11
lines changed
  • frontends/web/src/routes/device/bitbox02

1 file changed

+11
-11
lines changed

frontends/web/src/routes/device/bitbox02/wizard.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const Wizard = ({ deviceID }: TProps) => {
4141
verifyAttestation(deviceID).then(cb);
4242
})
4343
);
44-
const [appStatus, setAppStatus] = useState<'' | TWalletSetupChoices>('');
44+
const [setupChoice, setSetupChoice] = useState<'' | TWalletSetupChoices>('');
4545
const [createOptions, setCreateOptions] = useState<TWalletCreateOptions>();
4646
const [showWizard, setShowWizard] = useState<boolean>(false);
4747
// If true, we just pair and unlock, so we can hide some steps.
@@ -68,7 +68,7 @@ export const Wizard = ({ deviceID }: TProps) => {
6868
}, [status, showWizard, unlockOnly]);
6969

7070
const handleAbort = () => {
71-
setAppStatus('');
71+
setSetupChoice('');
7272
setCreateOptions(undefined);
7373
};
7474
if (status === undefined) {
@@ -91,7 +91,7 @@ export const Wizard = ({ deviceID }: TProps) => {
9191
return null;
9292
}
9393
// fixes empty main element, happens when after unlocking the device, reason wizard is now always mounted in app.tsx
94-
if (appStatus === '' && status === 'initialized') {
94+
if (setupChoice === '' && status === 'initialized') {
9595
return null;
9696
}
9797
return (
@@ -110,20 +110,20 @@ export const Wizard = ({ deviceID }: TProps) => {
110110
pairingFailed={status === 'pairingFailed'} />
111111
)}
112112

113-
{ (!unlockOnly && appStatus === '') && (
113+
{ (!unlockOnly && setupChoice === '') && (
114114
<SetupOptions
115115
key="choose-setup"
116116
versionInfo={versionInfo}
117117
onSelectSetup={(
118118
type: TWalletSetupChoices,
119119
createOptions?: TWalletCreateOptions,
120120
) => {
121-
setAppStatus(type);
121+
setSetupChoice(type);
122122
setCreateOptions(createOptions);
123123
}} />
124124
)}
125125

126-
{ (!unlockOnly && appStatus === 'create-wallet') && (
126+
{ (!unlockOnly && setupChoice === 'create-wallet') && (
127127
<CreateWallet
128128
backupType={(createOptions?.withMnemonic ? 'mnemonic' : 'sdcard')}
129129
backupSeedLength={createOptions?.with12Words ? 16 : 32}
@@ -133,30 +133,30 @@ export const Wizard = ({ deviceID }: TProps) => {
133133
)}
134134

135135
{/* keeping the backups mounted even restoreBackupStatus === 'restore' is not true so it catches potential errors */}
136-
{ (!unlockOnly && appStatus === 'restore-sdcard' && status !== 'initialized') && (
136+
{ (!unlockOnly && setupChoice === 'restore-sdcard' && status !== 'initialized') && (
137137
<RestoreFromSDCard
138138
key="restore-sdcard"
139139
deviceID={deviceID}
140140
onAbort={handleAbort} />
141141
)}
142142

143-
{ (!unlockOnly && appStatus === 'restore-mnemonic' && status !== 'initialized') && (
143+
{ (!unlockOnly && setupChoice === 'restore-mnemonic' && status !== 'initialized') && (
144144
<RestoreFromMnemonic
145145
key="restore-mnemonic"
146146
deviceID={deviceID}
147147
onAbort={handleAbort} />
148148
)}
149149

150-
{ (appStatus === 'create-wallet' && status === 'initialized') && (
150+
{ (setupChoice === 'create-wallet' && status === 'initialized') && (
151151
<CreateWalletSuccess
152152
key="success"
153153
backupType={(createOptions?.withMnemonic ? 'mnemonic' : 'sdcard')}
154154
onContinue={handleGetStarted} />
155155
)}
156-
{ (appStatus === 'restore-sdcard' && status === 'initialized') && (
156+
{ (setupChoice === 'restore-sdcard' && status === 'initialized') && (
157157
<RestoreFromSDCardSuccess key="backup-success" onContinue={handleGetStarted} />
158158
)}
159-
{ (appStatus === 'restore-mnemonic' && status === 'initialized') && (
159+
{ (setupChoice === 'restore-mnemonic' && status === 'initialized') && (
160160
<RestoreFromMnemonicSuccess key="backup-mnemonic-success" onContinue={handleGetStarted} />
161161
)}
162162
</Main>

0 commit comments

Comments
 (0)