diff --git a/components/publish/PublishWidget.vue b/components/publish/PublishWidget.vue index e97601a9..05646bc0 100644 --- a/components/publish/PublishWidget.vue +++ b/components/publish/PublishWidget.vue @@ -5,6 +5,8 @@ import { useDropZone } from '@vueuse/core' import { EditorContent } from '@tiptap/vue-3' import type { Draft } from '~/types' +type FileUploadError = [filename: string, message: string] + const { draftKey, initial = getDefaultDraft() as never /* Bug of vue-core */, @@ -57,7 +59,7 @@ const currentVisibility = $computed(() => { let isUploading = $ref(false) let isExceedingAttachmentLimit = $ref(false) -let failed = $ref([]) +let failed = $ref([]) async function handlePaste(evt: ClipboardEvent) { const files = evt.clipboardData?.files @@ -109,12 +111,12 @@ async function uploadAttachments(files: File[]) { catch (e) { // TODO: add some human-readable error message, problem is that masto api will not return response code console.error(e) - failed = [...failed, file] + failed = [...failed, [file.name, (e as Error).message]] } } else { isExceedingAttachmentLimit = true - failed = [...failed, file] + failed = [...failed, [file.name, t('state.attachments_limit_error')]] } } isUploading = false @@ -233,7 +235,7 @@ defineExpose({
-
+
{{ $t('state.attachments_exceed_server_limit') }}
    -
  1. - {{ file.name }} +
  2. + {{ error[1] }}: + {{ error[0] }}
diff --git a/locales/en-GB.json b/locales/en-GB.json index 847ef80c..6d12eb31 100644 --- a/locales/en-GB.json +++ b/locales/en-GB.json @@ -261,6 +261,7 @@ }, "state": { "attachments_exceed_server_limit": "The number of attachments exceeded the limit per post.", + "attachments_limit_error": "Limit per post exceeded", "edited": "(Edited)", "editing": "Editing", "loading": "Loading...", diff --git a/locales/en-US.json b/locales/en-US.json index cd10875c..d6f90a7e 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -261,6 +261,7 @@ }, "state": { "attachments_exceed_server_limit": "The number of attachments exceeded the limit per post.", + "attachments_limit_error": "Limit per post exceeded", "edited": "(Edited)", "editing": "Editing", "loading": "Loading...", diff --git a/locales/es-ES.json b/locales/es-ES.json index cd148177..8dbf9e34 100644 --- a/locales/es-ES.json +++ b/locales/es-ES.json @@ -251,6 +251,8 @@ } }, "state": { + "attachments_exceed_server_limit": "Número máximo de archivos adjuntos por publicación excedido.", + "attachments_limit_error": "Límite por publicación excedido", "edited": "(Editado)", "editing": "Editando", "loading": "Cargando...",