mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-09-04 13:46:34 +08:00
fix(commandline): prevent duplicate entries in Polyglot and Layoutfluid funbox modes (@byseif21) (#6684)
### Description #### Issue: * It was possible to add duplicate languages to Polyglot mode or duplicate layouts to Layoutfluid mode via the command line #### fix: * Prevent duplicate entries in Polyglot and Layoutfluid configs by deduplicating values before saving, ensuring unique values regardless of input source.
This commit is contained in:
parent
4fffc645f4
commit
64322a2ed1
1 changed files with 8 additions and 4 deletions
|
@ -1871,17 +1871,19 @@ export function setCustomLayoutfluid(
|
|||
value: ConfigSchemas.CustomLayoutFluid,
|
||||
nosave?: boolean
|
||||
): boolean {
|
||||
// Remove duplicates
|
||||
const deduped = Array.from(new Set(value));
|
||||
if (
|
||||
!isConfigValueValid(
|
||||
"layoutfluid",
|
||||
value,
|
||||
deduped,
|
||||
ConfigSchemas.CustomLayoutFluidSchema
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
config.customLayoutfluid = value;
|
||||
config.customLayoutfluid = deduped;
|
||||
saveToLocalStorage("customLayoutfluid", nosave);
|
||||
ConfigEvent.dispatch("customLayoutfluid", config.customLayoutfluid);
|
||||
|
||||
|
@ -1892,16 +1894,18 @@ export function setCustomPolyglot(
|
|||
value: ConfigSchemas.CustomPolyglot,
|
||||
nosave?: boolean
|
||||
): boolean {
|
||||
// remove duplicates
|
||||
const deduped = Array.from(new Set(value));
|
||||
if (
|
||||
!isConfigValueValid(
|
||||
"customPolyglot",
|
||||
value,
|
||||
deduped,
|
||||
ConfigSchemas.CustomPolyglotSchema
|
||||
)
|
||||
)
|
||||
return false;
|
||||
|
||||
config.customPolyglot = value;
|
||||
config.customPolyglot = deduped;
|
||||
saveToLocalStorage("customPolyglot", nosave);
|
||||
ConfigEvent.dispatch("customPolyglot", config.customPolyglot);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue