forked from Mirrors/elk
fix: respect instance media configuration (#615)
This commit is contained in:
parent
5e86d2a3da
commit
f780ed9be0
1 changed files with 9 additions and 19 deletions
|
@ -73,24 +73,12 @@ function insertCustomEmoji(image: any) {
|
|||
}
|
||||
|
||||
async function pickAttachments() {
|
||||
const files = await fileOpen([
|
||||
{
|
||||
const mimeTypes = currentInstance.value!.configuration.mediaAttachments.supportedMimeTypes
|
||||
const files = await fileOpen({
|
||||
description: 'Attachments',
|
||||
multiple: true,
|
||||
mimeTypes: ['image/*'],
|
||||
extensions: ['.png', '.gif', '.jpeg', '.jpg', '.webp', '.avif', '.heic', '.heif'],
|
||||
},
|
||||
{
|
||||
description: 'Attachments',
|
||||
mimeTypes: ['video/*'],
|
||||
extensions: ['.webm', '.mp4', '.m4v', '.mov', '.ogv', '.3gp'],
|
||||
},
|
||||
{
|
||||
description: 'Attachments',
|
||||
mimeTypes: ['audio/*'],
|
||||
extensions: ['.mp3', '.ogg', '.oga', '.wav', '.flac', '.opus', '.aac', '.m4a', '.3gp', '.wma'],
|
||||
},
|
||||
])
|
||||
mimeTypes,
|
||||
})
|
||||
await uploadAttachments(files)
|
||||
}
|
||||
|
||||
|
@ -103,7 +91,9 @@ const masto = useMasto()
|
|||
async function uploadAttachments(files: File[]) {
|
||||
isUploading = true
|
||||
failed = []
|
||||
for (const file of files) {
|
||||
// TODO: display some kind of message if too many media are selected
|
||||
const limit = currentInstance.value!.configuration.statuses.maxMediaAttachments || 4
|
||||
for (const file of files.slice(0, limit)) {
|
||||
try {
|
||||
const attachment = await masto.mediaAttachments.create({
|
||||
file,
|
||||
|
|
Loading…
Reference in a new issue