mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
web: fix error when registering task with invalid time (fixes #4890)
This commit is contained in:
@@ -24,12 +24,19 @@ import type {
|
|||||||
} from "./task-scheduler.worker";
|
} from "./task-scheduler.worker";
|
||||||
import { wrap, Remote } from "comlink";
|
import { wrap, Remote } from "comlink";
|
||||||
import { showToast } from "./toast";
|
import { showToast } from "./toast";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
import { logger } from "./logger";
|
||||||
|
|
||||||
let worker: globalThis.Worker | undefined;
|
let worker: globalThis.Worker | undefined;
|
||||||
let scheduler: Remote<TaskSchedulerType> | undefined;
|
let scheduler: Remote<TaskSchedulerType> | undefined;
|
||||||
|
|
||||||
export class TaskScheduler {
|
export class TaskScheduler {
|
||||||
static async register(id: string, time: string, action: () => void) {
|
static async register(id: string, time: string, action: () => void) {
|
||||||
|
if (!dayjs(time).isValid()) {
|
||||||
|
logger.error(`Invalid cron expression: ${time}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
worker?.addEventListener("message", function handler(ev) {
|
worker?.addEventListener("message", function handler(ev) {
|
||||||
|
|||||||
Reference in New Issue
Block a user