kopia lustrzana https://github.com/elk-zone/elk
fix: avoid returning `ScheduledStatus` when creating scheduled post
rodzic
d68d75cc2d
commit
e44d7ce00a
|
@ -59,7 +59,7 @@ export function usePublish(options: {
|
|||
failedMessages.value.length = 0
|
||||
}, { deep: true })
|
||||
|
||||
async function publishDraft() {
|
||||
async function publishDraft(): Promise<mastodon.v1.Status | undefined> {
|
||||
if (isPublishDisabled.value)
|
||||
return
|
||||
|
||||
|
@ -68,7 +68,6 @@ export function usePublish(options: {
|
|||
content = `${draft.value.mentions.map(i => `@${i}`).join(' ')} ${content}`
|
||||
|
||||
let poll
|
||||
|
||||
if (draft.value.params.poll) {
|
||||
let options = draft.value.params.poll.options
|
||||
|
||||
|
@ -83,9 +82,9 @@ export function usePublish(options: {
|
|||
poll = { ...draft.value.params.poll, options }
|
||||
}
|
||||
|
||||
let scheduledAt
|
||||
if (draft.value.params.scheduledAt)
|
||||
// TODO: return type become non `Status` object now! what to do?
|
||||
draft.value.params.scheduledAt = new Date(draft.value.params.scheduledAt).toISOString()
|
||||
scheduledAt = new Date(draft.value.params.scheduledAt).toISOString()
|
||||
|
||||
const payload = {
|
||||
...draft.value.params,
|
||||
|
@ -94,6 +93,7 @@ export function usePublish(options: {
|
|||
mediaIds: draft.value.attachments.map(a => a.id),
|
||||
language: draft.value.params.language || preferredLanguage.value,
|
||||
poll,
|
||||
scheduledAt,
|
||||
...(isGlitchEdition.value ? { 'content-type': 'text/markdown' } : {}),
|
||||
} as mastodon.rest.v1.CreateScheduledStatusParams
|
||||
|
||||
|
@ -115,6 +115,12 @@ export function usePublish(options: {
|
|||
let status: mastodon.v1.Status
|
||||
if (!draft.value.editingStatus) {
|
||||
status = await client.value.v1.statuses.create(payload)
|
||||
|
||||
if (scheduledAt)
|
||||
// When created a scheduled post, it returns `mastodon.v1.ScheduledStatus` instead
|
||||
// We want to return only Status, which will be used to route to the posted status page
|
||||
// ref. Mastodon documentation - https://docs.joinmastodon.org/methods/statuses/#create
|
||||
return
|
||||
}
|
||||
|
||||
else {
|
||||
|
|
Ładowanie…
Reference in New Issue