diff --git a/src/api/client.ts b/src/api/client.ts index 144d37a..2671554 100644 --- a/src/api/client.ts +++ b/src/api/client.ts @@ -209,7 +209,18 @@ export async function blobClient(path: string, signal?: AbortSignal): Promise (props.file ? getNoteFileUrl(props.noteId, props.file.id) : ""); const type = () => props.file?.content_type ?? ""; @@ -25,16 +27,21 @@ export function NoteFilePreview(props: { noteId: string; file: NoteFile | null; if (currentUrl) URL.revokeObjectURL(currentUrl); currentUrl = ""; setPreviewUrl(""); + setPreviewError(""); const file = props.file; if (!file || !canPreview(file)) return; const controller = new AbortController(); - void getNoteFileBlob(props.noteId, file.id, controller.signal).then((blob) => { - if (controller.signal.aborted) return; - currentUrl = URL.createObjectURL(blob); - setPreviewUrl(currentUrl); - }); + void getNoteFileBlob(props.noteId, file.id, controller.signal) + .then((blob) => { + if (controller.signal.aborted) return; + currentUrl = URL.createObjectURL(blob); + setPreviewUrl(currentUrl); + }) + .catch((err) => { + if (!controller.signal.aborted) setPreviewError(formatApiError(err)); + }); onCleanup(() => { controller.abort(); @@ -69,19 +76,21 @@ export function NoteFilePreview(props: { noteId: string; file: NoteFile | null; when={canPreview(file())} fallback={

{t("notes.previewUnsupported")}

} > - {t("common.loading")}

}> - {file().name} -
- - - -
-
-
- -