Skip to content

Commit b806179

Browse files
committed
fix: errors during word generation when custom text was empty
also migrate if an empty array was found in localstorage
1 parent b257a52 commit b806179

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

frontend/src/ts/modals/custom-text.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,11 @@ function apply(): void {
357357

358358
const text = cleanUpText();
359359

360+
if (text.length === 0) {
361+
Notifications.add("Text cannot be empty", 0);
362+
return;
363+
}
364+
360365
if (state.customTextMode === "simple") {
361366
CustomText.setMode("repeat");
362367
state.customTextLimits.word = `${text.length}`;

frontend/src/ts/test/custom-text.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const customTextLongLS = new LocalStorageWithSchema({
3131
});
3232

3333
export const CustomTextSettingsSchema = z.object({
34-
text: z.array(z.string()),
34+
text: z.array(z.string()).min(1),
3535
mode: CustomTextModeSchema,
3636
limit: z.object({ value: z.number(), mode: CustomTextLimitModeSchema }),
3737
pipeDelimiter: z.boolean(),

0 commit comments

Comments
 (0)