* Removes a timeblock from a daily note
( app: App, dailyNote: TFile, timeblockId: string )
| 898 | * Removes a timeblock from a daily note |
| 899 | */ |
| 900 | async function removeTimeblockFromDailyNote( |
| 901 | app: App, |
| 902 | dailyNote: TFile, |
| 903 | timeblockId: string |
| 904 | ): Promise<void> { |
| 905 | const content = await app.vault.read(dailyNote); |
| 906 | const frontmatter = |
| 907 | (extractFrontmatter(content) as DailyNoteFrontmatterWithTimeblocks | null) || {}; |
| 908 | |
| 909 | if (!frontmatter.timeblocks || !Array.isArray(frontmatter.timeblocks)) { |
| 910 | return; // No timeblocks to remove |
| 911 | } |
| 912 | |
| 913 | // Remove the timeblock |
| 914 | frontmatter.timeblocks = frontmatter.timeblocks.filter((tb) => tb.id !== timeblockId); |
| 915 | |
| 916 | // Save back to file |
| 917 | await updateDailyNoteFrontmatter(app, dailyNote, frontmatter, content); |
| 918 | } |
| 919 | |
| 920 | /** |
| 921 | * Adds a timeblock to a daily note (creating the note if needed) |
no test coverage detected