diff --git a/CHANGELOG.md b/CHANGELOG.md index da3e599..7da3d9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Changed custom emoji vertical alignment and size. - Expect `/api/v1/statuses` to return status code 200. - Insert application-name meta tag at build time. +- Disable post submission button while attachment is being uploaded. ## [1.13.0] - 2023-02-06 diff --git a/src/components/PostEditor.vue b/src/components/PostEditor.vue index e26bf76..604e014 100644 --- a/src/components/PostEditor.vue +++ b/src/components/PostEditor.vue @@ -172,6 +172,7 @@ let visibility = $ref(Visibility.Public) let visibilityMenuVisible = $ref(false) let preview = $ref(null) let isLoading = $ref(false) +let isAttachmentLoading = $ref(false) let errorMessage = $ref(null) const author = $computed(() => { @@ -231,7 +232,10 @@ function canAttachFile(): boolean { if (!instance) { return false } - return attachments.length < instance.configuration.statuses.max_media_attachments + return ( + attachments.length < instance.configuration.statuses.max_media_attachments && + !isAttachmentLoading + ) } function getAcceptedMediaTypes(): string { @@ -258,6 +262,7 @@ async function onAttachmentUpload(event: Event) { } async function addAttachment(file: File) { + isAttachmentLoading = true const imageDataUrl = await fileToDataUrl(file) const imageData = dataUrlToBase64(imageDataUrl) const attachment = await uploadAttachment( @@ -266,6 +271,7 @@ async function addAttachment(file: File) { imageData.mediaType, ) attachments.push(attachment) + isAttachmentLoading = false } function removeAttachment(index: number) { @@ -307,7 +313,7 @@ async function togglePreview() { } function canPublish(): boolean { - return getCharacterCount() >= 0 && !isLoading + return getCharacterCount() >= 0 && !isLoading && !isAttachmentLoading } async function publish() {