()
| 1788 | } |
| 1789 | |
| 1790 | async addProjectToCurrentTask(): Promise<void> { |
| 1791 | try { |
| 1792 | const activeFile = this.app.workspace.getActiveFile(); |
| 1793 | if (!activeFile) { |
| 1794 | new Notice("No file is currently open"); |
| 1795 | return; |
| 1796 | } |
| 1797 | |
| 1798 | const taskInfo = await this.cacheManager.getTaskInfo(activeFile.path); |
| 1799 | if (!taskInfo) { |
| 1800 | new Notice("Current file is not a task"); |
| 1801 | return; |
| 1802 | } |
| 1803 | |
| 1804 | const selector = new ProjectSelectModal(this.app, this, (projectFile) => { |
| 1805 | if (!(projectFile instanceof TFile)) { |
| 1806 | new Notice( |
| 1807 | this.i18n.translate( |
| 1808 | "contextMenus.task.organization.notices.projectSelectFailed" |
| 1809 | ) |
| 1810 | ); |
| 1811 | return; |
| 1812 | } |
| 1813 | void this.addSelectedProjectToTask(taskInfo, projectFile); |
| 1814 | }); |
| 1815 | selector.open(); |
| 1816 | } catch (error) { |
| 1817 | tasknotesLogger.error("Failed to add project to current task:", { |
| 1818 | category: "persistence", |
| 1819 | operation: "add-project-current-task", |
| 1820 | error: error, |
| 1821 | }); |
| 1822 | new Notice( |
| 1823 | this.i18n.translate("contextMenus.task.organization.notices.addToProjectFailed") |
| 1824 | ); |
| 1825 | } |
| 1826 | } |
| 1827 | |
| 1828 | async addSubtaskToCurrentNote(): Promise<void> { |
| 1829 | try { |
no test coverage detected