Skip to content

Commit 64322a2

Browse files
authored
fix(commandline): prevent duplicate entries in Polyglot and Layoutfluid funbox modes (@byseif21) (monkeytypegame#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.
1 parent 4fffc64 commit 64322a2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

frontend/src/ts/config.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,17 +1871,19 @@ export function setCustomLayoutfluid(
18711871
value: ConfigSchemas.CustomLayoutFluid,
18721872
nosave?: boolean
18731873
): boolean {
1874+
// Remove duplicates
1875+
const deduped = Array.from(new Set(value));
18741876
if (
18751877
!isConfigValueValid(
18761878
"layoutfluid",
1877-
value,
1879+
deduped,
18781880
ConfigSchemas.CustomLayoutFluidSchema
18791881
)
18801882
) {
18811883
return false;
18821884
}
18831885

1884-
config.customLayoutfluid = value;
1886+
config.customLayoutfluid = deduped;
18851887
saveToLocalStorage("customLayoutfluid", nosave);
18861888
ConfigEvent.dispatch("customLayoutfluid", config.customLayoutfluid);
18871889

@@ -1892,16 +1894,18 @@ export function setCustomPolyglot(
18921894
value: ConfigSchemas.CustomPolyglot,
18931895
nosave?: boolean
18941896
): boolean {
1897+
// remove duplicates
1898+
const deduped = Array.from(new Set(value));
18951899
if (
18961900
!isConfigValueValid(
18971901
"customPolyglot",
1898-
value,
1902+
deduped,
18991903
ConfigSchemas.CustomPolyglotSchema
19001904
)
19011905
)
19021906
return false;
19031907

1904-
config.customPolyglot = value;
1908+
config.customPolyglot = deduped;
19051909
saveToLocalStorage("customPolyglot", nosave);
19061910
ConfigEvent.dispatch("customPolyglot", config.customPolyglot);
19071911

0 commit comments

Comments
 (0)