( paths: string[], context: TaskNotesMutationContext | undefined, operation: () => Promise<T> )
| 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; |
no test coverage detected