( task: TaskInfo, plugin: TaskNotesPlugin )
| 116 | * Creates a click handler for recurrence indicators. |
| 117 | */ |
| 118 | export 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. |
no test coverage detected