From b80617913793f0fd5e43023f2b321d6a8d6840e9 Mon Sep 17 00:00:00 2001 From: Miodec Date: Sat, 3 May 2025 12:27:36 +0200 Subject: [PATCH] fix: errors during word generation when custom text was empty also migrate if an empty array was found in localstorage --- frontend/src/ts/modals/custom-text.ts | 5 +++++ frontend/src/ts/test/custom-text.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/src/ts/modals/custom-text.ts b/frontend/src/ts/modals/custom-text.ts index 8322c453a..1c29b0718 100644 --- a/frontend/src/ts/modals/custom-text.ts +++ b/frontend/src/ts/modals/custom-text.ts @@ -357,6 +357,11 @@ function apply(): void { const text = cleanUpText(); + if (text.length === 0) { + Notifications.add("Text cannot be empty", 0); + return; + } + if (state.customTextMode === "simple") { CustomText.setMode("repeat"); state.customTextLimits.word = `${text.length}`; diff --git a/frontend/src/ts/test/custom-text.ts b/frontend/src/ts/test/custom-text.ts index bc5cdb84f..844e4ec62 100644 --- a/frontend/src/ts/test/custom-text.ts +++ b/frontend/src/ts/test/custom-text.ts @@ -31,7 +31,7 @@ const customTextLongLS = new LocalStorageWithSchema({ }); export const CustomTextSettingsSchema = z.object({ - text: z.array(z.string()), + text: z.array(z.string()).min(1), mode: CustomTextModeSchema, limit: z.object({ value: z.number(), mode: CustomTextLimitModeSchema }), pipeDelimiter: z.boolean(),