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

Method withMutationContext

src/api/TaskNotesAPI.ts:2689–2718  ·  view source on GitHub ↗
(
		paths: string[],
		context: TaskNotesMutationContext | undefined,
		operation: () => Promise<T>
	)

Source from the content-addressed store, hash-verified

2687 }
2688
2689 private async withMutationContext<T>(
2690 paths: string[],
2691 context: TaskNotesMutationContext | undefined,
2692 operation: () => Promise<T>
2693 ): Promise<T> {
2694 if (!context) {
2695 return operation();
2696 }
2697
2698 const normalizedPaths = paths.map((path) => normalizePath(path));
2699 for (const path of normalizedPaths) {
2700 const contexts = this.mutationContextByPath.get(path) ?? [];
2701 contexts.push(context);
2702 this.mutationContextByPath.set(path, contexts);
2703 }
2704 this.mutationContextStack.push(context);
2705
2706 try {
2707 return await operation();
2708 } finally {
2709 for (const path of normalizedPaths) {
2710 const contexts = this.mutationContextByPath.get(path);
2711 contexts?.pop();
2712 if (!contexts?.length) {
2713 this.mutationContextByPath.delete(path);
2714 }
2715 }
2716 this.mutationContextStack.pop();
2717 }
2718 }
2719
2720 private normalizeUpdatedEvent(payload: TaskUpdatedEventPayload): TaskNotesApiEventPayload[] {
2721 const before = payload.originalTask ? copyTaskInfo(payload.originalTask) : undefined;

Callers 15

createTaskMethod · 0.95
updateTaskMethod · 0.95
completeTaskMethod · 0.95
rescheduleTaskMethod · 0.95
archiveTaskMethod · 0.95
moveTaskMethod · 0.95
deleteTaskMethod · 0.95
uncompleteTaskMethod · 0.95
setTaskPropertyMethod · 0.95
startTimeMethod · 0.95
stopTimeMethod · 0.95
deleteTimeEntryMethod · 0.95

Calls 4

normalizePathFunction · 0.90
getMethod · 0.65
setMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected