fix: respect instance media configuration (#615)
This commit is contained in:
parent
5e86d2a3da
commit
f780ed9be0
|
@ -73,24 +73,12 @@ function insertCustomEmoji(image: any) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function pickAttachments() {
|
async function pickAttachments() {
|
||||||
const files = await fileOpen([
|
const mimeTypes = currentInstance.value!.configuration.mediaAttachments.supportedMimeTypes
|
||||||
{
|
const files = await fileOpen({
|
||||||
description: 'Attachments',
|
description: 'Attachments',
|
||||||
multiple: true,
|
multiple: true,
|
||||||
mimeTypes: ['image/*'],
|
mimeTypes,
|
||||||
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'],
|
|
||||||
},
|
|
||||||
])
|
|
||||||
await uploadAttachments(files)
|
await uploadAttachments(files)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +91,9 @@ const masto = useMasto()
|
||||||
async function uploadAttachments(files: File[]) {
|
async function uploadAttachments(files: File[]) {
|
||||||
isUploading = true
|
isUploading = true
|
||||||
failed = []
|
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 {
|
try {
|
||||||
const attachment = await masto.mediaAttachments.create({
|
const attachment = await masto.mediaAttachments.create({
|
||||||
file,
|
file,
|
||||||
|
|
Loading…
Reference in a new issue