Skip to content

Commit 1553958

Browse files
only21milcodex
andcommitted
fix(mobile): accept comma decimals in scheduled task intervals
Normalize decimal commas before converting interval minutes so decimal-pad input can be saved. Share the parser with the minimum-interval hint and show the hint for nonnumeric input. Co-Authored-By: GPT-6.1 Sol <[email protected]>
1 parent c2fb438 commit 1553958

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import { SettingsSection } from "./components/SettingsSection";
6666
import { useSettingsEnvironmentFilter, type SettingsTarget } from "./settings-environment-filter";
6767
import {
6868
editDraft,
69+
parseIntervalMinutes,
6970
scheduledTaskDefaultModel,
7071
scheduleFromDraft,
7172
type ScheduledTaskDraft as Draft,
@@ -977,7 +978,7 @@ function TaskForm({
977978
setDraft({ ...draft, schedule: { ...draft.schedule, intervalMinutes } })
978979
}
979980
/>
980-
{Number(draft.schedule.intervalMinutes) < 1 ? (
981+
{!(parseIntervalMinutes(draft.schedule.intervalMinutes) >= 1) ? (
981982
<Text className="px-4 pb-3 text-sm text-danger-foreground">
982983
Intervals must be at least 1 minute. Update this interval before saving.
983984
</Text>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ describe("scheduleFromDraft", () => {
196196

197197
it.each([
198198
["1.5", 90_000],
199+
["2,5", 150_000],
200+
[" 2,5 ", 150_000],
199201
["1000001", 60_000_060_000],
200202
[String(60_001 / 60_000), 60_001],
201203
[String(65_000 / 60_000), 65_000],
@@ -207,7 +209,7 @@ describe("scheduleFromDraft", () => {
207209
});
208210
});
209211

210-
it.each(["NaN", "Infinity", "9007199254740991", "0.5"])(
212+
it.each(["NaN", "Infinity", "9007199254740991", "0.5", "0,5", "2,5,0"])(
211213
"rejects intervals that cannot be written as safe whole milliseconds: %s",
212214
(intervalMinutes) => {
213215
expect(

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

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

93+
export function parseIntervalMinutes(value: string): number {
94+
return Number(value.trim().replace(",", "."));
95+
}
96+
9397
export function scheduleFromDraft(draft: ScheduleDraft): ScheduledTaskUpsertSchedule | null {
9498
if (draft.mode === "webhook") {
9599
const maxDeliveryAgeMinutes = parseMaxDeliveryAge(draft.maxDeliveryAgeMinutes);
@@ -109,7 +113,7 @@ export function scheduleFromDraft(draft: ScheduleDraft): ScheduledTaskUpsertSche
109113
};
110114
}
111115
if (draft.mode === "interval") {
112-
const minutes = Number(draft.intervalMinutes);
116+
const minutes = parseIntervalMinutes(draft.intervalMinutes);
113117
const everyMs = Math.round(minutes * 60_000);
114118
return minutes >= 1 && Number.isSafeInteger(everyMs) ? { type: "interval", everyMs } : null;
115119
}

0 commit comments

Comments
 (0)