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")}
}>
-
-
-
-
-
-
-
-
-
-
+ {previewError()}}>
+ {t("common.loading")}}>
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/notes/note-files-panel.tsx b/src/components/notes/note-files-panel.tsx
index dee0443..4cba1c6 100644
--- a/src/components/notes/note-files-panel.tsx
+++ b/src/components/notes/note-files-panel.tsx
@@ -4,7 +4,7 @@ import { getNoteFileUrl } from "@/api/getNoteFileUrl";
import { getNoteFiles } from "@/api/getNoteFiles";
import { getSettings } from "@/api/getSettings";
import { postNoteFile } from "@/api/postNoteFile";
-import { ApiError, formatApiError } from "@/api/client";
+import { formatApiError } from "@/api/client";
import type { NoteFile } from "@/api/types";
import { NoteFilePreview } from "@/components/notes/note-file-preview";
import { Button } from "@/components/ui/button";
@@ -65,13 +65,7 @@ export function NoteFilesPanel(props: { noteId: string; active: boolean }) {
() => (props.active ? props.noteId : null),
async (noteId) => {
if (!noteId) return [] as NoteFile[];
- // ponytail: empty on 404 so missing BE file API doesn't kill the reader dialog
- try {
- return (await getNoteFiles(noteId, { limit: MAX_NOTE_FILES })).items;
- } catch (err) {
- if (err instanceof ApiError && (err.status === 404 || err.status === 501)) return [];
- throw err;
- }
+ return (await getNoteFiles(noteId, { limit: MAX_NOTE_FILES })).items;
},
);
const [settings] = createResource(async () => {
diff --git a/src/i18n/messages.ts b/src/i18n/messages.ts
index 7d7088f..f0f2bb3 100644
--- a/src/i18n/messages.ts
+++ b/src/i18n/messages.ts
@@ -184,6 +184,7 @@ export type MessageKey =
| "notes.noFiles"
| "notes.fileLimit"
| "notes.fileTooLarge"
+ | "notes.fileUploadPartial"
| "notes.previewUnsupported"
| "notes.unknownFileType"
| "notes.helpTitle"
@@ -710,6 +711,7 @@ const en: Dict = {
"notes.noFiles": "No files attached.",
"notes.fileLimit": "This note already has 10 files.",
"notes.fileTooLarge": "File is too large. Max {size}.",
+ "notes.fileUploadPartial": "Note saved, but {count} file(s) could not be uploaded.",
"notes.previewUnsupported": "Preview is not available for this file type. Download the file to open it.",
"notes.unknownFileType": "Unknown file type",
"notes.helpTitle": "About notes",
@@ -1248,6 +1250,7 @@ const tr: Dict = {
"notes.noFiles": "Henüz dosya eklenmemiş.",
"notes.fileLimit": "Bu notta zaten 10 dosya var.",
"notes.fileTooLarge": "Dosya çok büyük. En fazla {size}.",
+ "notes.fileUploadPartial": "Not kaydedildi ama {count} dosya yüklenemedi.",
"notes.previewUnsupported": "Bu dosya türü için önizleme yok. Açmak için dosyayı indirin.",
"notes.unknownFileType": "Bilinmeyen dosya türü",
"notes.helpTitle": "Notlar hakkında",
diff --git a/src/pages/notes-page.tsx b/src/pages/notes-page.tsx
index facde62..1abaf12 100644
--- a/src/pages/notes-page.tsx
+++ b/src/pages/notes-page.tsx
@@ -86,16 +86,22 @@ function NotesContent() {
submitLabel={t("common.create")}
onCancel={() => setCreateOpen(false)}
onSubmit={async (values) => {
+ setError("");
const note = await postNote({
title: values.title,
content: values.content || undefined,
});
- // ponytail: upload after create — file API needs note id
+ let failedUploads = 0;
for (const file of values.files) {
- await postNoteFile(note.id, file);
+ try {
+ await postNoteFile(note.id, file);
+ } catch {
+ failedUploads += 1;
+ }
}
await refetch();
setCreateOpen(false);
+ if (failedUploads > 0) setError(t("notes.fileUploadPartial", { count: failedUploads }));
}}
/>