( note: ZenNote, onDelete: (path: string) => void, )
| 336 | } |
| 337 | |
| 338 | async function moveNoteToTrash( |
| 339 | note: ZenNote, |
| 340 | onDelete: (path: string) => void, |
| 341 | ): Promise<void> { |
| 342 | const confirmed = await confirmAlert({ |
| 343 | title: `Move "${note.title}" to Trash?`, |
| 344 | message: note.path, |
| 345 | primaryAction: { |
| 346 | title: "Move to Trash", |
| 347 | style: Alert.ActionStyle.Destructive, |
| 348 | }, |
| 349 | }); |
| 350 | if (!confirmed) return; |
| 351 | |
| 352 | const toast = await showToast({ |
| 353 | style: Toast.Style.Animated, |
| 354 | title: "Moving note to Trash", |
| 355 | message: note.title, |
| 356 | }); |
| 357 | |
| 358 | try { |
| 359 | await execZen(["trash", note.path, "--json"]); |
| 360 | onDelete(note.path); |
| 361 | toast.style = Toast.Style.Success; |
| 362 | toast.title = "Moved to Trash"; |
| 363 | toast.message = note.title; |
| 364 | } catch (err) { |
| 365 | const loadError = toLoadError(err); |
| 366 | toast.style = Toast.Style.Failure; |
| 367 | toast.title = loadError.title; |
| 368 | toast.message = loadError.message; |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | function noteKeywords(note: ZenNote): string[] { |
| 373 | return [note.path, note.folder, ...note.tags.map((tag) => `#${tag}`)]; |
no test coverage detected