MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / handleCalendarTaskClick

Function handleCalendarTaskClick

src/utils/clickHandlers.ts:280–347  ·  view source on GitHub ↗
(
	task: TaskInfo,
	plugin: TaskNotesPlugin,
	jsEvent: MouseEvent,
	eventId: string,
	onTaskUpdated?: () => void
)

Source from the content-addressed store, hash-verified

278 * This is designed to be used in FullCalendar's eventClick handler
279 */
280export async function handleCalendarTaskClick(
281 task: TaskInfo,
282 plugin: TaskNotesPlugin,
283 jsEvent: MouseEvent,
284 eventId: string,
285 onTaskUpdated?: () => void
286) {
287 const openNote = (newTab = false) => {
288 const file = plugin.app.vault.getAbstractFileByPath(task.path);
289 if (file instanceof TFile) {
290 if (newTab) {
291 void plugin.app.workspace.openLinkText(task.path, "", true);
292 } else {
293 void plugin.app.workspace.getLeaf(false).openFile(file);
294 }
295 }
296 };
297
298 const editTask = async () => {
299 await plugin.openTaskEditModal(task, onTaskUpdated ? () => onTaskUpdated() : undefined);
300 };
301
302 const handleSingleClick = async (e: MouseEvent) => {
303 if (e.ctrlKey || e.metaKey) {
304 openNote(true); // Open in new tab
305 return;
306 }
307
308 const action = plugin.settings.singleClickAction;
309 if (action === "edit") {
310 await editTask();
311 } else if (action === "openNote") {
312 openNote(false); // Open in current tab
313 }
314 };
315
316 const handleDoubleClick = async (e: MouseEvent) => {
317 const action = plugin.settings.doubleClickAction;
318 if (action === "edit") {
319 await editTask();
320 } else if (action === "openNote") {
321 openNote();
322 }
323 };
324
325 // If double-click is disabled, handle single click immediately
326 if (plugin.settings.doubleClickAction === "none") {
327 await handleSingleClick(jsEvent);
328 return;
329 }
330
331 // Check if we have a pending click for this event
332 const existingTimeout = calendarClickTimeouts.get(eventId);
333
334 if (existingTimeout) {
335 // This is a double-click
336 window.clearTimeout(existingTimeout);
337 calendarClickTimeouts.delete(eventId);

Callers 1

handleEventClickMethod · 0.90

Calls 7

handleSingleClickFunction · 0.85
handleDoubleClickFunction · 0.85
getMethod · 0.65
clearTimeoutMethod · 0.65
deleteMethod · 0.65
setTimeoutMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected