(menu: Menu, file: TAbstractFile, source?: string)
| 332 | } |
| 333 | |
| 334 | addTaskNotesFileMenuActions(menu: Menu, file: TAbstractFile, source?: string): void { |
| 335 | if (source === "tasknotes-context-menu") { |
| 336 | return; |
| 337 | } |
| 338 | |
| 339 | if (!(file instanceof TFile)) { |
| 340 | return; |
| 341 | } |
| 342 | |
| 343 | const metadata = this.app.metadataCache.getFileCache(file); |
| 344 | if (!metadata?.frontmatter || !this.cacheManager.isTaskFile(metadata.frontmatter)) { |
| 345 | return; |
| 346 | } |
| 347 | |
| 348 | menu.addSeparator(); |
| 349 | menu.addItem((item) => { |
| 350 | item.setTitle(this.i18n.translate("modals.taskEdit.title")); |
| 351 | item.setIcon("pencil"); |
| 352 | item.setSection("tasknotes"); |
| 353 | item.onClick(() => { |
| 354 | void this.openTaskEditModalForFile(file); |
| 355 | }); |
| 356 | }); |
| 357 | |
| 358 | const task = this.cacheManager.getCachedTaskInfoSync(file.path); |
| 359 | if (!task) { |
| 360 | return; |
| 361 | } |
| 362 | |
| 363 | menu.addItem((item) => { |
| 364 | item.setTitle(this.i18n.translate("common.appName")); |
| 365 | item.setIcon("list-checks"); |
| 366 | item.setSection("tasknotes"); |
| 367 | const submenu = getSubmenu(item); |
| 368 | TaskContextMenu.addToMenu(submenu, { |
| 369 | task, |
| 370 | plugin: this, |
| 371 | targetDate: getTodayLocal(), |
| 372 | onUpdate: () => { |
| 373 | this.app.workspace.trigger("tasknotes:refresh-views"); |
| 374 | }, |
| 375 | }); |
| 376 | }); |
| 377 | } |
| 378 | |
| 379 | /** |
| 380 | * Initialize HTTP API service (desktop only) |
no test coverage detected