MCPcopy Create free account
hub / github.com/callumalpass/tasknotes / removeTimeblockFromDailyNote

Function removeTimeblockFromDailyNote

src/utils/helpers.ts:900–918  ·  view source on GitHub ↗

* Removes a timeblock from a daily note

(
	app: App,
	dailyNote: TFile,
	timeblockId: string
)

Source from the content-addressed store, hash-verified

898 * Removes a timeblock from a daily note
899 */
900async 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)

Callers 1

Calls 3

extractFrontmatterFunction · 0.70
readMethod · 0.45

Tested by

no test coverage detected