parent
e596953ada
commit
29fe2a10ac
|
@ -5,6 +5,8 @@ import { useDropZone } from '@vueuse/core'
|
||||||
import { EditorContent } from '@tiptap/vue-3'
|
import { EditorContent } from '@tiptap/vue-3'
|
||||||
import type { Draft } from '~/types'
|
import type { Draft } from '~/types'
|
||||||
|
|
||||||
|
type FileUploadError = [filename: string, message: string]
|
||||||
|
|
||||||
const {
|
const {
|
||||||
draftKey,
|
draftKey,
|
||||||
initial = getDefaultDraft() as never /* Bug of vue-core */,
|
initial = getDefaultDraft() as never /* Bug of vue-core */,
|
||||||
|
@ -57,7 +59,7 @@ const currentVisibility = $computed(() => {
|
||||||
|
|
||||||
let isUploading = $ref<boolean>(false)
|
let isUploading = $ref<boolean>(false)
|
||||||
let isExceedingAttachmentLimit = $ref<boolean>(false)
|
let isExceedingAttachmentLimit = $ref<boolean>(false)
|
||||||
let failed = $ref<File[]>([])
|
let failed = $ref<FileUploadError[]>([])
|
||||||
|
|
||||||
async function handlePaste(evt: ClipboardEvent) {
|
async function handlePaste(evt: ClipboardEvent) {
|
||||||
const files = evt.clipboardData?.files
|
const files = evt.clipboardData?.files
|
||||||
|
@ -109,12 +111,12 @@ async function uploadAttachments(files: File[]) {
|
||||||
catch (e) {
|
catch (e) {
|
||||||
// TODO: add some human-readable error message, problem is that masto api will not return response code
|
// TODO: add some human-readable error message, problem is that masto api will not return response code
|
||||||
console.error(e)
|
console.error(e)
|
||||||
failed = [...failed, file]
|
failed = [...failed, [file.name, (e as Error).message]]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
isExceedingAttachmentLimit = true
|
isExceedingAttachmentLimit = true
|
||||||
failed = [...failed, file]
|
failed = [...failed, [file.name, t('state.attachments_limit_error')]]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isUploading = false
|
isUploading = false
|
||||||
|
@ -233,7 +235,7 @@ defineExpose({
|
||||||
<div
|
<div
|
||||||
v-else-if="failed.length > 0"
|
v-else-if="failed.length > 0"
|
||||||
role="alert"
|
role="alert"
|
||||||
aria-describedby="upload-failed"
|
:aria-describedby="isExceedingAttachmentLimit ? 'upload-failed uploads-per-post' : 'upload-failed'"
|
||||||
flex="~ col"
|
flex="~ col"
|
||||||
gap-1 text-sm
|
gap-1 text-sm
|
||||||
pt-1 ps-2 pe-1 pb-2
|
pt-1 ps-2 pe-1 pb-2
|
||||||
|
@ -256,12 +258,13 @@ defineExpose({
|
||||||
</button>
|
</button>
|
||||||
</CommonTooltip>
|
</CommonTooltip>
|
||||||
</head>
|
</head>
|
||||||
<div v-if="isExceedingAttachmentLimit" ps-2 sm:ps-1 text-small>
|
<div v-if="isExceedingAttachmentLimit" id="uploads-per-post" ps-2 sm:ps-1 text-small>
|
||||||
{{ $t('state.attachments_exceed_server_limit') }}
|
{{ $t('state.attachments_exceed_server_limit') }}
|
||||||
</div>
|
</div>
|
||||||
<ol ps-2 sm:ps-1>
|
<ol ps-2 sm:ps-1>
|
||||||
<li v-for="file in failed" :key="file.name">
|
<li v-for="error in failed" :key="error[0]" flex="~ col sm:row" gap-y-1 sm:gap-x-2>
|
||||||
{{ file.name }}
|
<strong>{{ error[1] }}:</strong>
|
||||||
|
<span>{{ error[0] }}</span>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -261,6 +261,7 @@
|
||||||
},
|
},
|
||||||
"state": {
|
"state": {
|
||||||
"attachments_exceed_server_limit": "The number of attachments exceeded the limit per post.",
|
"attachments_exceed_server_limit": "The number of attachments exceeded the limit per post.",
|
||||||
|
"attachments_limit_error": "Limit per post exceeded",
|
||||||
"edited": "(Edited)",
|
"edited": "(Edited)",
|
||||||
"editing": "Editing",
|
"editing": "Editing",
|
||||||
"loading": "Loading...",
|
"loading": "Loading...",
|
||||||
|
|
|
@ -261,6 +261,7 @@
|
||||||
},
|
},
|
||||||
"state": {
|
"state": {
|
||||||
"attachments_exceed_server_limit": "The number of attachments exceeded the limit per post.",
|
"attachments_exceed_server_limit": "The number of attachments exceeded the limit per post.",
|
||||||
|
"attachments_limit_error": "Limit per post exceeded",
|
||||||
"edited": "(Edited)",
|
"edited": "(Edited)",
|
||||||
"editing": "Editing",
|
"editing": "Editing",
|
||||||
"loading": "Loading...",
|
"loading": "Loading...",
|
||||||
|
|
|
@ -251,6 +251,8 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"state": {
|
"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)",
|
"edited": "(Editado)",
|
||||||
"editing": "Editando",
|
"editing": "Editando",
|
||||||
"loading": "Cargando...",
|
"loading": "Cargando...",
|
||||||
|
|
Loading…
Reference in New Issue