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

Method batchDelete

src/components/BatchContextMenu.ts:530–589  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

528 }
529
530 private async batchDelete(): Promise<void> {
531 const { plugin, selectedPaths, onUpdate } = this.options;
532 const count = selectedPaths.length;
533
534 // Show confirmation dialog
535 const confirmed = await showConfirmationModal(plugin.app, {
536 title: "Delete tasks",
537 message: `Are you sure you want to delete ${count} tasks? This action cannot be undone.`,
538 confirmText: "Delete",
539 cancelText: this.t("common.cancel"),
540 isDestructive: true,
541 });
542
543 if (!confirmed) return;
544
545 try {
546 new Notice(`Deleting ${count} tasks...`);
547
548 let successCount = 0;
549 let failCount = 0;
550
551 for (const path of selectedPaths) {
552 try {
553 const task = await plugin.cacheManager.getTaskInfo(path);
554 if (task) {
555 await plugin.taskService.deleteTask(task);
556 successCount++;
557 } else {
558 failCount++;
559 }
560 } catch (e) {
561 tasknotesLogger.error(`[BatchContextMenu] Failed to delete task ${path}:`, {
562 category: "persistence",
563 operation: "delete-task",
564 error: e,
565 });
566 failCount++;
567 }
568 }
569
570 if (failCount === 0) {
571 new Notice(`Deleted ${successCount} tasks`);
572 } else {
573 new Notice(`Deleted ${successCount} tasks, ${failCount} failed`);
574 }
575
576 // Clear selection after successful batch operation
577 plugin.taskSelectionService?.clearSelection();
578 plugin.taskSelectionService?.exitSelectionMode();
579
580 onUpdate?.();
581 } catch (error) {
582 tasknotesLogger.error("[BatchContextMenu] Batch delete failed:", {
583 category: "persistence",
584 operation: "batch-delete",
585 error: error,
586 });
587 new Notice("Failed to delete tasks");

Callers 1

buildMenuMethod · 0.95

Calls 7

tMethod · 0.95
showConfirmationModalFunction · 0.90
errorMethod · 0.80
clearSelectionMethod · 0.80
exitSelectionModeMethod · 0.80
getTaskInfoMethod · 0.65
deleteTaskMethod · 0.45

Tested by

no test coverage detected