Skip to content

Commit a22ea56

Browse files
committed
refactor: Remove unused NavSettings props
1 parent c4b3635 commit a22ea56

File tree

1 file changed

+107
-134
lines changed

1 file changed

+107
-134
lines changed

src/components/nav/NavSettings.tsx

Lines changed: 107 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,7 @@ export const GAME_MODES = (t: TFunction) => [
5656
{ value: 'wvw', label: t('WvW') },
5757
];
5858

59-
interface NavSettingsProps {
60-
disableSettings?: {
61-
language?: boolean;
62-
expertMode?: boolean;
63-
gameMode?: boolean;
64-
threading?: boolean;
65-
};
66-
}
67-
68-
export default function NavSettings({
69-
disableSettings: {
70-
language: languageDisabled,
71-
expertMode: expertModeDisabled,
72-
gameMode: gameModeDisabled,
73-
threading: threadingDisabled,
74-
} = {},
75-
}: NavSettingsProps) {
59+
export default function NavSettings() {
7660
const { t } = useTranslation();
7761
const dispatch = useAppDispatch();
7862
const { classes } = useStyles();
@@ -115,131 +99,120 @@ export default function NavSettings({
11599
Optimizer version: {__COMMIT_HASH__}
116100
</Typography>
117101
)}
102+
118103
<Divider className={classes.divider} />
119-
{!expertModeDisabled && (
120-
<>
121-
<FormControlLabel
122-
control={
123-
<Switch
124-
checked={expertMode}
125-
onChange={(e) => {
126-
dispatch(stopCalc);
127-
dispatch(changeExpertMode(e.target.checked));
128-
}}
129-
name="checked"
130-
color="primary"
131-
/>
132-
}
133-
label={t('Expert')}
134-
/>
135-
<Divider className={classes.divider} />
136-
</>
137-
)}
138-
{!languageDisabled && <LanguageSelection />}
139-
140-
{!gameModeDisabled && (
141-
<>
142-
<FormControl sx={{ minWidth: 150 }} size="small" variant="standard">
143-
<FormLabel id="gamemode-button-group">
144-
<Trans>Game Mode</Trans>
145-
</FormLabel>
146-
147-
<RadioGroup
148-
aria-labelledby="gamemode-select-label"
149-
value={gameMode}
150-
onChange={(e) => {
151-
const newGameMode = e.target.value as GameMode;
152-
dispatch(changeGameMode(newGameMode));
153-
154-
const isFractalsNew = newGameMode === 'fractals';
155-
const isFractalsOld = gameMode === 'fractals';
156-
const isFractalsChanged = isFractalsNew !== isFractalsOld;
157-
if (isFractalsChanged && selectedTemplate && selectedTemplate.length > 0)
158-
setOpen(true);
159-
}}
160-
color="primary"
161-
>
162-
{GAME_MODES(t).map(({ value, label }) => (
163-
<FormControlLabel key={value} value={value} control={<Radio />} label={label} />
164-
))}
165-
</RadioGroup>
166-
</FormControl>
167-
<ReapplyTemplateDialog open={open} handleClose={handleClose} />
168-
</>
169-
)}
170104

171-
{!threadingDisabled && (
172-
<>
173-
<Divider className={classes.divider} />
174-
175-
<TextField
176-
label={t('Threads')}
177-
helperText={t('Number of threads to use for calculations')}
178-
placeholder={String(defaultHwThreads)}
179-
size="small"
180-
value={hwThreadsString}
181-
error={hwThreadsError}
182-
onChange={(e) => dispatch(changeHwThreads(e.target.value))}
183-
slotProps={{
184-
htmlInput: { inputMode: 'numeric', pattern: '[0-9]*' },
185-
input: {
186-
// used to always display the placeholder value instead of the label
187-
// eslint-disable-next-line react/jsx-no-useless-fragment
188-
startAdornment: <></>,
189-
},
105+
<FormControlLabel
106+
control={
107+
<Switch
108+
checked={expertMode}
109+
onChange={(e) => {
110+
dispatch(stopCalc);
111+
dispatch(changeExpertMode(e.target.checked));
190112
}}
113+
name="checked"
114+
color="primary"
191115
/>
116+
}
117+
label={t('Expert')}
118+
/>
192119

193-
<Divider className={classes.divider} />
194-
195-
<FormControlLabel
196-
control={
197-
<Checkbox
198-
onChange={(e) => {
199-
if (!enableMulticore) {
200-
dispatch(stopCalc);
201-
} else {
202-
// workers.forEach(({ worker }) => worker.postMessage({ type: STOP }));
203-
dispatch(stopCalculationParallel);
204-
}
205-
206-
const newMulticore = e.target.checked;
207-
dispatch(changeMulticore(newMulticore));
208-
}}
209-
/>
210-
}
211-
label={t('Enable experimental Rust/WebAssembly mode')}
212-
checked={enableMulticore}
213-
/>
120+
<Divider className={classes.divider} />
214121

215-
<FormControlLabel
216-
control={
217-
<Checkbox
218-
onChange={(e) => {
219-
const newHeuristics = e.target.checked;
220-
dispatch(changeHeuristics(newHeuristics));
221-
}}
222-
/>
223-
}
224-
label={t('Enable heuristics')}
225-
sx={{ display: 'none' }}
226-
checked={enableHeuristics}
227-
/>
122+
<LanguageSelection />
123+
124+
<FormControl sx={{ minWidth: 150 }} size="small" variant="standard">
125+
<FormLabel id="gamemode-button-group">
126+
<Trans>Game Mode</Trans>
127+
</FormLabel>
128+
129+
<RadioGroup
130+
aria-labelledby="gamemode-select-label"
131+
value={gameMode}
132+
onChange={(e) => {
133+
const newGameMode = e.target.value as GameMode;
134+
dispatch(changeGameMode(newGameMode));
135+
136+
const isFractalsNew = newGameMode === 'fractals';
137+
const isFractalsOld = gameMode === 'fractals';
138+
const isFractalsChanged = isFractalsNew !== isFractalsOld;
139+
if (isFractalsChanged && selectedTemplate && selectedTemplate.length > 0) setOpen(true);
140+
}}
141+
color="primary"
142+
>
143+
{GAME_MODES(t).map(({ value, label }) => (
144+
<FormControlLabel key={value} value={value} control={<Radio />} label={label} />
145+
))}
146+
</RadioGroup>
147+
</FormControl>
148+
<ReapplyTemplateDialog open={open} handleClose={handleClose} />
228149

229-
<FormControlLabel
230-
control={
231-
<Checkbox
232-
onChange={(e) => {
233-
dispatch(changeIncludeScenarioDataInCharacters(e.target.checked));
234-
}}
235-
/>
236-
}
237-
label={t('Include scenario data in internal character JSON')}
238-
slotProps={{ typography: { variant: 'caption' } }}
239-
checked={includeScenarioDataInCharacters}
150+
<Divider className={classes.divider} />
151+
152+
<TextField
153+
label={t('Threads')}
154+
helperText={t('Number of threads to use for calculations')}
155+
placeholder={String(defaultHwThreads)}
156+
size="small"
157+
value={hwThreadsString}
158+
error={hwThreadsError}
159+
onChange={(e) => dispatch(changeHwThreads(e.target.value))}
160+
slotProps={{
161+
htmlInput: { inputMode: 'numeric', pattern: '[0-9]*' },
162+
input: {
163+
// used to always display the placeholder value instead of the label
164+
// eslint-disable-next-line react/jsx-no-useless-fragment
165+
startAdornment: <></>,
166+
},
167+
}}
168+
/>
169+
170+
<Divider className={classes.divider} />
171+
172+
<FormControlLabel
173+
control={
174+
<Checkbox
175+
onChange={(e) => {
176+
if (!enableMulticore) {
177+
dispatch(stopCalc);
178+
} else {
179+
// workers.forEach(({ worker }) => worker.postMessage({ type: STOP }));
180+
dispatch(stopCalculationParallel);
181+
}
182+
183+
const newMulticore = e.target.checked;
184+
dispatch(changeMulticore(newMulticore));
185+
}}
240186
/>
241-
</>
242-
)}
187+
}
188+
label={t('Enable experimental Rust/WebAssembly mode')}
189+
checked={enableMulticore}
190+
/>
191+
<FormControlLabel
192+
control={
193+
<Checkbox
194+
onChange={(e) => {
195+
const newHeuristics = e.target.checked;
196+
dispatch(changeHeuristics(newHeuristics));
197+
}}
198+
/>
199+
}
200+
label={t('Enable heuristics')}
201+
sx={{ display: 'none' }}
202+
checked={enableHeuristics}
203+
/>
204+
<FormControlLabel
205+
control={
206+
<Checkbox
207+
onChange={(e) => {
208+
dispatch(changeIncludeScenarioDataInCharacters(e.target.checked));
209+
}}
210+
/>
211+
}
212+
label={t('Include scenario data in internal character JSON')}
213+
slotProps={{ typography: { variant: 'caption' } }}
214+
checked={includeScenarioDataInCharacters}
215+
/>
243216
</Settings>
244217
);
245218
}

0 commit comments

Comments
 (0)