()
| 1826 | } |
| 1827 | |
| 1828 | async addSubtaskToCurrentNote(): Promise<void> { |
| 1829 | try { |
| 1830 | const activeFile = this.app.workspace.getActiveFile(); |
| 1831 | if (!activeFile) { |
| 1832 | new Notice("No file is currently open"); |
| 1833 | return; |
| 1834 | } |
| 1835 | |
| 1836 | const allTasks = await this.cacheManager.getAllTasks(); |
| 1837 | const candidates = allTasks.filter((candidate) => candidate.path !== activeFile.path); |
| 1838 | if (candidates.length === 0) { |
| 1839 | new Notice( |
| 1840 | this.i18n.translate("contextMenus.task.organization.notices.noEligibleSubtasks") |
| 1841 | ); |
| 1842 | return; |
| 1843 | } |
| 1844 | |
| 1845 | openTaskSelector(this, candidates, (subtask) => { |
| 1846 | if (!subtask) return; |
| 1847 | void this.assignSelectedSubtaskToCurrentNote(activeFile, subtask); |
| 1848 | }); |
| 1849 | } catch (error) { |
| 1850 | tasknotesLogger.error("Failed to add subtask to current note:", { |
| 1851 | category: "persistence", |
| 1852 | operation: "add-subtask-current-note", |
| 1853 | error: error, |
| 1854 | }); |
| 1855 | new Notice( |
| 1856 | this.i18n.translate("contextMenus.task.organization.notices.subtaskSelectFailed") |
| 1857 | ); |
| 1858 | } |
| 1859 | } |
| 1860 | |
| 1861 | private async addSelectedProjectToTask(task: TaskInfo, projectFile: TFile): Promise<void> { |
| 1862 | try { |
no test coverage detected