feat: poll creation (#2111)
This commit is contained in:
parent
d9add9f670
commit
1fda33848e
6 changed files with 237 additions and 88 deletions
|
@ -34,7 +34,15 @@ export function usePublish(options: {
|
|||
|
||||
const shouldExpanded = $computed(() => expanded || isExpanded || !isEmpty)
|
||||
const isPublishDisabled = $computed(() => {
|
||||
return isEmpty || isUploading || isSending || (draft.attachments.length === 0 && !draft.params.status) || failedMessages.length > 0
|
||||
return isEmpty
|
||||
|| isUploading
|
||||
|| isSending
|
||||
|| (draft.attachments.length === 0 && !draft.params.status)
|
||||
|| failedMessages.length > 0
|
||||
|| (draft.attachments.length > 0 && draft.params.poll !== null && draft.params.poll !== undefined)
|
||||
|| (draft.params.poll !== null && draft.params.poll !== undefined && draft.params.poll.options.length <= 1)
|
||||
|| (draft.params.poll !== null && draft.params.poll !== undefined && ![-1, draft.params.poll.options.length - 1].includes(draft.params.poll.options.findIndex(option => option.trim().length === 0)))
|
||||
|| (draft.params.poll !== null && draft.params.poll !== undefined && new Set(draft.params.poll.options).size !== draft.params.poll.options.length)
|
||||
})
|
||||
|
||||
watch(() => draft, () => {
|
||||
|
@ -56,6 +64,7 @@ export function usePublish(options: {
|
|||
status: content,
|
||||
mediaIds: draft.attachments.map(a => a.id),
|
||||
language: draft.params.language || preferredLanguage,
|
||||
poll: draft.params.poll ? { ...draft.params.poll, options: draft.params.poll.options.slice(0, draft.params.poll.options.length - 1) } : undefined,
|
||||
...(isGlitchEdition.value ? { 'content-type': 'text/markdown' } : {}),
|
||||
} as mastodon.v1.CreateStatusParams
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue