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

Function createRecurrenceClickHandler

src/ui/taskCardActions.ts:118–156  ·  view source on GitHub ↗
(
	task: TaskInfo,
	plugin: TaskNotesPlugin
)

Source from the content-addressed store, hash-verified

116 * Creates a click handler for recurrence indicators.
117 */
118export function createRecurrenceClickHandler(
119 task: TaskInfo,
120 plugin: TaskNotesPlugin
121): (e: MouseEvent) => void {
122 return (e: MouseEvent) => {
123 e.stopPropagation();
124 const menu = new RecurrenceContextMenu({
125 currentValue: typeof task.recurrence === "string" ? task.recurrence : undefined,
126 currentAnchor: task.recurrence_anchor || "scheduled",
127 scheduledDate: task.scheduled,
128 onSelect: (newRecurrence, anchor) => {
129 void (async () => {
130 const logger = getTaskCardActionLogger(plugin);
131 try {
132 await plugin.updateTaskProperty(
133 task,
134 "recurrence",
135 newRecurrence || undefined
136 );
137 if (anchor !== undefined) {
138 await plugin.updateTaskProperty(task, "recurrence_anchor", anchor);
139 }
140 } catch (error) {
141 logger.error("Error updating recurrence", {
142 category: "persistence",
143 operation: "update-recurrence",
144 details: { taskPath: task.path, newRecurrence, anchor },
145 error,
146 });
147 new Notice("Failed to update recurrence");
148 }
149 })();
150 },
151 app: plugin.app,
152 plugin,
153 });
154 menu.show(e);
155 };
156}
157
158/**
159 * Creates a click handler for reminder indicators.

Calls 4

showMethod · 0.95
getTaskCardActionLoggerFunction · 0.85
updateTaskPropertyMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected