fix: errors during word generation when custom text was empty

also migrate if an empty array was found in localstorage
This commit is contained in:
Miodec 2025-05-03 12:27:36 +02:00
parent b257a52f41
commit b806179137
2 changed files with 6 additions and 1 deletions

View file

@ -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}`;

View file

@ -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(),