feat: support showing publish failed messages (#1209)
This commit is contained in:
parent
0b2b9a713b
commit
85e163a0ad
7 changed files with 93 additions and 17 deletions
|
@ -16,12 +16,18 @@ export const usePublish = (options: {
|
|||
|
||||
let isSending = $ref(false)
|
||||
const isExpanded = $ref(false)
|
||||
const failedMessages = $ref<string[]>([])
|
||||
|
||||
const shouldExpanded = $computed(() => expanded || isExpanded || !isEmpty)
|
||||
const isPublishDisabled = $computed(() => {
|
||||
return isEmpty || isUploading || isSending || (draft.attachments.length === 0 && !draft.params.status)
|
||||
return isEmpty || isUploading || isSending || (draft.attachments.length === 0 && !draft.params.status) || failedMessages.length > 0
|
||||
})
|
||||
|
||||
watch(() => draft, () => {
|
||||
if (failedMessages.length > 0)
|
||||
failedMessages.length = 0
|
||||
}, { deep: true })
|
||||
|
||||
async function publishDraft() {
|
||||
let content = htmlToText(draft.params.status || '')
|
||||
if (draft.mentions?.length)
|
||||
|
@ -63,6 +69,7 @@ export const usePublish = (options: {
|
|||
}
|
||||
catch (err) {
|
||||
console.error(err)
|
||||
failedMessages.push((err as Error).message)
|
||||
}
|
||||
finally {
|
||||
isSending = false
|
||||
|
@ -74,6 +81,7 @@ export const usePublish = (options: {
|
|||
isExpanded,
|
||||
shouldExpanded,
|
||||
isPublishDisabled,
|
||||
failedMessages,
|
||||
|
||||
publishDraft,
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue