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 ### Changed
- Show alert if publishing of reply fails. - Show alert if publishing of reply fails.
- Show alert if attachment upload fails.
### Fixed ### Fixed

View file

@ -265,11 +265,18 @@ async function addAttachment(file: File) {
isAttachmentLoading = true isAttachmentLoading = true
const imageDataUrl = await fileToDataUrl(file) const imageDataUrl = await fileToDataUrl(file)
const imageData = dataUrlToBase64(imageDataUrl) const imageData = dataUrlToBase64(imageDataUrl)
const attachment = await uploadAttachment( let attachment
try {
attachment = await uploadAttachment(
ensureAuthToken(), ensureAuthToken(),
imageData.data, imageData.data,
imageData.mediaType, imageData.mediaType,
) )
} catch (error: any) {
isAttachmentLoading = false
alert(error.message)
return
}
attachments.push(attachment) attachments.push(attachment)
isAttachmentLoading = false isAttachmentLoading = false
} }