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

Function updateNoteArchiveState

integrations/raycast/src/search-notes.tsx:308–336  ·  view source on GitHub ↗
(
  note: ZenNote,
  action: "archive" | "unarchive",
  onUpdate: (oldPath: string, updatedNote: ZenNote) => void,
)

Source from the content-addressed store, hash-verified

306}
307
308async function updateNoteArchiveState(
309 note: ZenNote,
310 action: "archive" | "unarchive",
311 onUpdate: (oldPath: string, updatedNote: ZenNote) => void,
312): Promise<void> {
313 const verb = action === "archive" ? "Archiving" : "Unarchiving";
314 const done = action === "archive" ? "Archived" : "Unarchived";
315 const toast = await showToast({
316 style: Toast.Style.Animated,
317 title: `${verb} note`,
318 message: note.title,
319 });
320
321 try {
322 const { stdout } = await execZen([action, note.path, "--json"]);
323 const updatedNote = parseNote(JSON.parse(String(stdout)) as unknown);
324 if (!updatedNote)
325 throw new Error(`Expected \`zn ${action} --json\` to return a note.`);
326 onUpdate(note.path, updatedNote);
327 toast.style = Toast.Style.Success;
328 toast.title = `${done} note`;
329 toast.message = updatedNote.title;
330 } catch (err) {
331 const loadError = toLoadError(err);
332 toast.style = Toast.Style.Failure;
333 toast.title = loadError.title;
334 toast.message = loadError.message;
335 }
336}
337
338async function moveNoteToTrash(
339 note: ZenNote,

Callers 1

NoteActionsFunction · 0.85

Calls 3

execZenFunction · 0.90
parseNoteFunction · 0.90
toLoadErrorFunction · 0.90

Tested by

no test coverage detected