MCPcopy
hub / github.com/callumalpass/tasknotes / initializeServicesLazily

Function initializeServicesLazily

src/bootstrap/pluginBootstrap.ts:332–514  ·  view source on GitHub ↗
(plugin: TaskNotesPlugin)

Source from the content-addressed store, hash-verified

330}
331
332export function initializeServicesLazily(plugin: TaskNotesPlugin): void {
333 window.setTimeout(() => {
334 void (async () => {
335 try {
336 if (!plugin.pomodoroService) {
337 plugin.pomodoroService = new PomodoroService(plugin);
338 await plugin.pomodoroService.initialize();
339 }
340
341 plugin.autoExportService = new AutoExportService(plugin);
342 plugin.autoExportService.start();
343
344 if (!isCalendarIntegrationDisabledOnMobile(plugin.settings)) {
345 await plugin.icsSubscriptionService.initialize();
346
347 plugin.googleCalendarService.on("data-changed", () => {
348 plugin.notifyDataChanged(undefined, false, true);
349 });
350 await plugin.googleCalendarService.initialize();
351
352 plugin.taskCalendarSyncService = new (
353 await import("../services/TaskCalendarSyncService")
354 ).TaskCalendarSyncService(plugin, plugin.googleCalendarService);
355 await plugin.taskCalendarSyncService.initializeExternalFileReconciliation();
356 plugin.taskCalendarSyncService.startRecoveryQueueProcessor();
357
358 plugin.registerEvent(
359 plugin.emitter.on("file-updated", (data: FileUpdatedEventData) => {
360 if (!plugin.taskCalendarSyncService || !data?.path) {
361 return;
362 }
363
364 plugin.taskCalendarSyncService
365 .handleExternalTaskFileUpdated(data.path, data.updatedTask)
366 .catch((error) => {
367 tasknotesLogger.warn(
368 "Failed to reconcile externally updated task with Google Calendar:",
369 {
370 category: "provider",
371 operation: "reconcile-external-task-file-update",
372 error: error,
373 }
374 );
375 });
376 })
377 );
378
379 plugin.registerEvent(
380 plugin.emitter.on("file-deleted", (data: FileDeletedEventData) => {
381 if (!plugin.taskCalendarSyncService) {
382 return;
383 }
384
385 const eventIdKey =
386 plugin.fieldMapper.toUserField("googleCalendarEventId");
387 const exceptionEventIdKey = plugin.fieldMapper.toUserField(
388 "googleCalendarExceptionEventId"
389 );

Callers 2

Tested by

no test coverage detected