forked from Mirrors/elk
fix: display error if attachments exceed limit (#666)
This commit is contained in:
parent
53fc28bf61
commit
4713db9adc
3 changed files with 22 additions and 8 deletions
|
@ -54,6 +54,7 @@ const currentVisibility = $computed(() => {
|
||||||
})
|
})
|
||||||
|
|
||||||
let isUploading = $ref<boolean>(false)
|
let isUploading = $ref<boolean>(false)
|
||||||
|
let isExceedingAttachmentLimit = $ref<boolean>(false)
|
||||||
let failed = $ref<File[]>([])
|
let failed = $ref<File[]>([])
|
||||||
|
|
||||||
async function handlePaste(evt: ClipboardEvent) {
|
async function handlePaste(evt: ClipboardEvent) {
|
||||||
|
@ -92,8 +93,11 @@ async function uploadAttachments(files: File[]) {
|
||||||
isUploading = true
|
isUploading = true
|
||||||
failed = []
|
failed = []
|
||||||
// TODO: display some kind of message if too many media are selected
|
// TODO: display some kind of message if too many media are selected
|
||||||
|
// DONE
|
||||||
const limit = currentInstance.value!.configuration.statuses.maxMediaAttachments || 4
|
const limit = currentInstance.value!.configuration.statuses.maxMediaAttachments || 4
|
||||||
for (const file of files.slice(0, limit)) {
|
for (const file of files.slice(0, limit)) {
|
||||||
|
if (draft.attachments.length < limit) {
|
||||||
|
isExceedingAttachmentLimit = false
|
||||||
try {
|
try {
|
||||||
const attachment = await masto.mediaAttachments.create({
|
const attachment = await masto.mediaAttachments.create({
|
||||||
file,
|
file,
|
||||||
|
@ -106,6 +110,11 @@ async function uploadAttachments(files: File[]) {
|
||||||
failed = [...failed, file]
|
failed = [...failed, file]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
isExceedingAttachmentLimit = true
|
||||||
|
failed = [...failed, file]
|
||||||
|
}
|
||||||
|
}
|
||||||
isUploading = false
|
isUploading = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,6 +255,9 @@ defineExpose({
|
||||||
</button>
|
</button>
|
||||||
</CommonTooltip>
|
</CommonTooltip>
|
||||||
</head>
|
</head>
|
||||||
|
<div v-if="isExceedingAttachmentLimit" pl-2 sm:pl-1 text-small>
|
||||||
|
{{ $t('state.attachments_exceed_server_limit') }}
|
||||||
|
</div>
|
||||||
<ol pl-2 sm:pl-1>
|
<ol pl-2 sm:pl-1>
|
||||||
<li v-for="file in failed" :key="file.name">
|
<li v-for="file in failed" :key="file.name">
|
||||||
{{ file.name }}
|
{{ file.name }}
|
||||||
|
|
|
@ -260,6 +260,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"state": {
|
"state": {
|
||||||
|
"attachments_exceed_server_limit": "The number of attachments exceeded the limit per post.",
|
||||||
"edited": "(Edited)",
|
"edited": "(Edited)",
|
||||||
"editing": "Editing",
|
"editing": "Editing",
|
||||||
"loading": "Loading...",
|
"loading": "Loading...",
|
||||||
|
|
|
@ -260,6 +260,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"state": {
|
"state": {
|
||||||
|
"attachments_exceed_server_limit": "The number of attachments exceeded the limit per post.",
|
||||||
"edited": "(Edited)",
|
"edited": "(Edited)",
|
||||||
"editing": "Editing",
|
"editing": "Editing",
|
||||||
"loading": "Loading...",
|
"loading": "Loading...",
|
||||||
|
|
Loading…
Reference in a new issue