diff --git a/composables/masto/publish.ts b/composables/masto/publish.ts index 8569a852..f56f70c6 100644 --- a/composables/masto/publish.ts +++ b/composables/masto/publish.ts @@ -62,7 +62,7 @@ export function usePublish(options: { failedMessages.value.length = 0 }, { deep: true }) - async function publishDraft() { + async function publishDraft(): Promise { if (isPublishDisabled.value) return @@ -71,7 +71,6 @@ export function usePublish(options: { content = `${draftItem.value.mentions.map(i => `@${i}`).join(' ')} ${content}` let poll - if (draftItem.value.params.poll) { let options = draftItem.value.params.poll.options @@ -86,9 +85,9 @@ export function usePublish(options: { poll = { ...draftItem.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 = { ...draftItem.value.params, @@ -97,6 +96,7 @@ export function usePublish(options: { mediaIds: draftItem.value.attachments.map(a => a.id), language: draftItem.value.params.language || preferredLanguage.value, poll, + scheduledAt, ...(isGlitchEdition.value ? { 'content-type': 'text/markdown' } : {}), } as mastodon.rest.v1.CreateScheduledStatusParams @@ -118,6 +118,12 @@ export function usePublish(options: { let status: mastodon.v1.Status if (!draftItem.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 {