mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 11:21:11 +00:00
chore(cron): simplify enabled checks for lint
This commit is contained in:
@@ -55,7 +55,7 @@ export function findJobOrThrow(state: CronServiceState, id: string) {
|
||||
}
|
||||
|
||||
export function computeJobNextRunAtMs(job: CronJob, nowMs: number): number | undefined {
|
||||
if (job.enabled === false) {
|
||||
if (!job.enabled) {
|
||||
return undefined;
|
||||
}
|
||||
if (job.schedule.kind === "every") {
|
||||
@@ -102,7 +102,7 @@ function normalizeJobTickState(params: { state: CronServiceState; job: CronJob;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (job.enabled === false) {
|
||||
if (!job.enabled) {
|
||||
if (job.state.nextRunAtMs !== undefined) {
|
||||
job.state.nextRunAtMs = undefined;
|
||||
changed = true;
|
||||
@@ -220,9 +220,7 @@ export function recomputeNextRunsForMaintenance(state: CronServiceState): boolea
|
||||
|
||||
export function nextWakeAtMs(state: CronServiceState) {
|
||||
const jobs = state.store?.jobs ?? [];
|
||||
const enabled = jobs.filter(
|
||||
(j) => j.enabled !== false && typeof j.state.nextRunAtMs === "number",
|
||||
);
|
||||
const enabled = jobs.filter((j) => j.enabled && typeof j.state.nextRunAtMs === "number");
|
||||
if (enabled.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -482,11 +480,7 @@ export function isJobDue(job: CronJob, nowMs: number, opts: { forced: boolean })
|
||||
if (opts.forced) {
|
||||
return true;
|
||||
}
|
||||
return (
|
||||
job.enabled !== false &&
|
||||
typeof job.state.nextRunAtMs === "number" &&
|
||||
nowMs >= job.state.nextRunAtMs
|
||||
);
|
||||
return job.enabled && typeof job.state.nextRunAtMs === "number" && nowMs >= job.state.nextRunAtMs;
|
||||
}
|
||||
|
||||
export function resolveJobPayloadTextForMain(job: CronJob): string | undefined {
|
||||
|
||||
Reference in New Issue
Block a user