fix(offline): don't abort cache loop on a single fetch failure

A single null from queryFileContent silently exited cacheAllNotes,
leaving every later note uncached while the success toast still fired.
Skip the failing file, count failures, and surface them via errorMessage.
This commit is contained in:
Julien Calixte
2026-05-16 23:31:42 +02:00
parent fc4ed188d7
commit c5236b2587
2 changed files with 15 additions and 5 deletions

View File

@@ -1,14 +1,20 @@
<script setup lang="ts">
import { useOfflineNotes } from "@/hooks/useOfflineNotes.hook"
import { confirmMessage } from "@/utils/notif"
import { confirmMessage, errorMessage } from "@/utils/notif"
const { cacheAllNotes, isLoading, totalOfNotes, noteCompleted } =
const { cacheAllNotes, isLoading, totalOfNotes, noteCompleted, failedNotes } =
useOfflineNotes()
const confirmBeforeCachingAllNotes = async () => {
confirm("Do you want to cache all notes?")
await cacheAllNotes()
confirmMessage("✅ All notes have been locally saved")
if (failedNotes.value > 0) {
errorMessage(
`${failedNotes.value} of ${totalOfNotes.value} note(s) could not be cached — try again`
)
} else {
confirmMessage("✅ All notes have been locally saved")
}
}
</script>