diff --git a/CHANGELOG.md b/CHANGELOG.md index 44ed94d..4c02d7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed - Show alert if publishing of reply fails. +- Show alert if attachment upload fails. ### Fixed diff --git a/src/components/PostEditor.vue b/src/components/PostEditor.vue index 2eaae09..25fd419 100644 --- a/src/components/PostEditor.vue +++ b/src/components/PostEditor.vue @@ -265,11 +265,18 @@ async function addAttachment(file: File) { isAttachmentLoading = true const imageDataUrl = await fileToDataUrl(file) const imageData = dataUrlToBase64(imageDataUrl) - const attachment = await uploadAttachment( - ensureAuthToken(), - imageData.data, - imageData.mediaType, - ) + let attachment + try { + attachment = await uploadAttachment( + ensureAuthToken(), + imageData.data, + imageData.mediaType, + ) + } catch (error: any) { + isAttachmentLoading = false + alert(error.message) + return + } attachments.push(attachment) isAttachmentLoading = false }