From f3306dd5333cedfbe0a713b8dc31f9b80ffbf044 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Burak=20Boduro=C4=9Flu?=
<80620802+burakboduroglu@users.noreply.github.com>
Date: Fri, 17 Jul 2026 19:24:40 +0300
Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20notes=20file=20upload=20e?=
=?UTF-8?q?rror=20handling=20and=20preview=20resilience=20-=20blobClient?=
=?UTF-8?q?=20parses=20JSON=20error=20body=20instead=20of=20bare=20status?=
=?UTF-8?q?=20text=20-=20NoteFilePreview=20shows=20fetch=20errors=20inline?=
=?UTF-8?q?=20instead=20of=20hanging=20-=20NoteFilesPanel=20removed=20404/?=
=?UTF-8?q?501=20catch-all=20=E2=80=94=20backend=20file=20API=20live=20-?=
=?UTF-8?q?=20NotesPage=20reports=20partial=20file=20upload=20failures=20o?=
=?UTF-8?q?n=20create=20-=20Added=20fileUploadPartial=20i18n=20keys=20(en/?=
=?UTF-8?q?tr)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/client.ts | 13 ++++++-
src/components/notes/note-file-preview.tsx | 45 +++++++++++++---------
src/components/notes/note-files-panel.tsx | 10 +----
src/i18n/messages.ts | 3 ++
src/pages/notes-page.tsx | 10 ++++-
5 files changed, 52 insertions(+), 29 deletions(-)
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 }));
}}
/>