From c7751d90519383ce3f183bc334ab03e7e74bab5d Mon Sep 17 00:00:00 2001 From: Christian Fehmer Date: Tue, 15 Oct 2024 11:43:55 +0200 Subject: [PATCH] fix: allow only one funbox changing capitalisation (@fehmer) (#5959) Fixes funboxes like `capitals` and `instant messaging` not working at the same time. --- backend/src/utils/validation.ts | 5 +++++ frontend/src/ts/test/funbox/funbox-validation.ts | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/backend/src/utils/validation.ts b/backend/src/utils/validation.ts index a36ea508c..e5ef947e4 100644 --- a/backend/src/utils/validation.ts +++ b/backend/src/utils/validation.ts @@ -136,6 +136,10 @@ export function areFunboxesCompatible(funboxesString: string): boolean { const oneCharReplacerMax = funboxesToCheck.filter((f) => f.frontendFunctions?.includes("getWordHtml")) .length <= 1; + const oneChangesCapitalisationMax = + funboxesToCheck.filter((f) => + f.properties?.find((fp) => fp === "changesCapitalisation") + ).length <= 1; const allowedConfig = {} as Record; let noConfigConflicts = true; for (const f of funboxesToCheck) { @@ -174,6 +178,7 @@ export function areFunboxesCompatible(funboxesString: string): boolean { onePunctuateWordMax && oneCharCheckerMax && oneCharReplacerMax && + oneChangesCapitalisationMax && noConfigConflicts && oneWordOrderMax ); diff --git a/frontend/src/ts/test/funbox/funbox-validation.ts b/frontend/src/ts/test/funbox/funbox-validation.ts index 31b132b9d..0f0bf1cfd 100644 --- a/frontend/src/ts/test/funbox/funbox-validation.ts +++ b/frontend/src/ts/test/funbox/funbox-validation.ts @@ -296,6 +296,10 @@ export function areFunboxesCompatible( funboxesToCheck.filter((f) => f.functions?.isCharCorrect).length <= 1; const oneCharReplacerMax = funboxesToCheck.filter((f) => f.functions?.getWordHtml).length <= 1; + const oneChangesCapitalisationMax = + funboxesToCheck.filter((f) => + f.properties?.find((fp) => fp === "changesCapitalisation") + ).length <= 1; const allowedConfig = {} as FunboxForcedConfig; let noConfigConflicts = true; for (const f of funboxesToCheck) { @@ -335,6 +339,7 @@ export function areFunboxesCompatible( onePunctuateWordMax && oneCharCheckerMax && oneCharReplacerMax && + oneChangesCapitalisationMax && noConfigConflicts ); }