MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / writeNoteComments

Function writeNoteComments

apps/desktop/src/main/vault.ts:2729–2744  ·  view source on GitHub ↗
(
  root: string,
  rel: string,
  comments: NoteCommentInput[]
)

Source from the content-addressed store, hash-verified

2727}
2728
2729export async function writeNoteComments(
2730 root: string,
2731 rel: string,
2732 comments: NoteCommentInput[]
2733): Promise<NoteComment[]> {
2734 const notePath = toPosix(rel)
2735 const normalized = normalizeNoteComments(comments, notePath)
2736 const abs = noteCommentsPath(root, notePath)
2737 if (normalized.length === 0) {
2738 await fs.rm(abs, { force: true })
2739 return []
2740 }
2741 await fs.mkdir(path.dirname(abs), { recursive: true })
2742 await fs.writeFile(abs, JSON.stringify({ version: 1, comments: normalized }, null, 2), 'utf8')
2743 return normalized
2744}
2745
2746async function removeNoteComments(root: string, rel: string): Promise<void> {
2747 await fs.rm(noteCommentsPath(root, rel), { force: true })

Callers 3

registerIpcFunction · 0.90
moveNoteCommentsFunction · 0.70
copyNoteCommentsFunction · 0.70

Calls 3

normalizeNoteCommentsFunction · 0.85
noteCommentsPathFunction · 0.85
toPosixFunction · 0.70

Tested by

no test coverage detected