Skip to content

Commit 5fd3639

Browse files
only21milcodexclaudemaria-rcks
authored
fix(mobile): accept comma decimals in scheduled task intervals (#22158)
Co-authored-by: GPT-6.1 Sol <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: maria-rcks <[email protected]>
1 parent f477008 commit 5fd3639

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎apps/mobile/src/features/settings/SettingsScheduledTasksRouteScreen.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ import { SettingsSection } from "./components/SettingsSection";
7272
import { useSettingsEnvironmentFilter, type SettingsTarget } from "./settings-environment-filter";
7373
import {
7474
editDraft,
75+
parseIntervalMinutes,
7576
scheduledTaskDefaultModel,
7677
scheduleFromDraft,
7778
type ScheduledTaskDraft as Draft,
@@ -1127,7 +1128,7 @@ function TaskForm({
11271128
setDraft({ ...draft, schedule: { ...draft.schedule, intervalMinutes } })
11281129
}
11291130
/>
1130-
{Number(draft.schedule.intervalMinutes) < 1 ? (
1131+
{!(parseIntervalMinutes(draft.schedule.intervalMinutes) >= 1) ? (
11311132
<Text className="px-4 pb-3 text-sm text-danger-foreground">
11321133
Intervals must be at least 1 minute. Update this interval before saving.
11331134
</Text>

‎apps/mobile/src/features/settings/scheduledTaskDraft.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,24 @@ describe("scheduleFromDraft", () => {
8989

9090
it.each([
9191
["1.5", 90_000],
92+
["2,5", 150_000],
93+
[" 2,5 ", 150_000],
9294
[String(60_001 / 60_000), 60_001],
9395
])("preserves a valid %s minute interval when saving", (intervalMinutes, everyMs) => {
9496
expect(scheduleFromDraft({ ...DEFAULT_SCHEDULE, mode: "interval", intervalMinutes })).toEqual({
9597
type: "interval",
9698
everyMs,
9799
});
98100
});
101+
102+
it.each(["0,5", "2,5,0", "Infinity", "150119987580", ""])(
103+
"rejects invalid interval minutes: %s",
104+
(intervalMinutes) => {
105+
expect(
106+
scheduleFromDraft({ ...DEFAULT_SCHEDULE, mode: "interval", intervalMinutes }),
107+
).toBeNull();
108+
},
109+
);
99110
});
100111

101112
describe("scheduled task model defaults", () => {

‎apps/mobile/src/features/settings/scheduledTaskDraft.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ export function scheduleDraftForTask(task: Pick<ScheduledTask, "schedule">): Sch
116116
}
117117
}
118118

119+
export function parseIntervalMinutes(value: string): number {
120+
return Number(value.trim().replace(",", "."));
121+
}
122+
119123
export function scheduleFromDraft(draft: ScheduleDraft): ScheduledTaskUpsertSchedule | null {
120124
if (draft.mode === "webhook") {
121125
const maxDeliveryAgeMinutes = parseMaxDeliveryAge(draft.maxDeliveryAgeMinutes);
@@ -163,7 +167,7 @@ export function scheduleFromDraft(draft: ScheduleDraft): ScheduledTaskUpsertSche
163167
};
164168
}
165169
if (draft.mode === "interval") {
166-
const minutes = Number(draft.intervalMinutes);
170+
const minutes = parseIntervalMinutes(draft.intervalMinutes);
167171
const everyMs = Math.round(minutes * 60_000);
168172
return minutes >= 1 && Number.isSafeInteger(everyMs) ? { type: "interval", everyMs } : null;
169173
}

0 commit comments

Comments
 (0)