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:
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user