Show alert if attachment upload fails

This commit is contained in:
silverpill 2023-03-14 16:50:43 +00:00
parent ccffafea21
commit 7d999c18a6
2 changed files with 13 additions and 5 deletions

View file

@ -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

View file

@ -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
}