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:
Seif Soliman 2025-07-01 14:00:57 +03:00 committed by GitHub
parent 4fffc645f4
commit 64322a2ed1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);