feat(offline): record structured failures during note caching

Expose a failures list alongside the existing failedNotes counter so each
failure carries kind/path/sha/message. Also catches throws from
buildNoteDocs and bulkUpdate that previously aborted the whole loop.
This commit is contained in:
Julien Calixte
2026-05-17 00:07:20 +02:00
parent 2994839ee5
commit e5dcdac65a

View File

@@ -2,13 +2,20 @@
import { useOfflineNotes } from "@/hooks/useOfflineNotes.hook" import { useOfflineNotes } from "@/hooks/useOfflineNotes.hook"
import { confirmMessage, errorMessage } from "@/utils/notif" import { confirmMessage, errorMessage } from "@/utils/notif"
const { cacheAllNotes, isLoading, totalOfNotes, noteCompleted, failedNotes } = const {
useOfflineNotes() cacheAllNotes,
isLoading,
totalOfNotes,
noteCompleted,
failedNotes,
failures
} = useOfflineNotes()
const confirmBeforeCachingAllNotes = async () => { const confirmBeforeCachingAllNotes = async () => {
confirm("Do you want to cache all notes?") confirm("Do you want to cache all notes?")
await cacheAllNotes() await cacheAllNotes()
if (failedNotes.value > 0) { if (failedNotes.value > 0) {
console.table(failures.value)
errorMessage( errorMessage(
`${failedNotes.value} of ${totalOfNotes.value} note(s) could not be cached — try again` `${failedNotes.value} of ${totalOfNotes.value} note(s) could not be cached — try again`
) )