From d975c6fc2c4af9a164ade01dac58e9831aa2cb8a Mon Sep 17 00:00:00 2001 From: Sma11X <540351143@qq.com> Date: Wed, 2 Aug 2023 18:31:08 +0800 Subject: [PATCH] fix: add attributes before status update (#2293) --- composables/masto/publish.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/composables/masto/publish.ts b/composables/masto/publish.ts index 569c8fbf..9c5ed276 100644 --- a/composables/masto/publish.ts +++ b/composables/masto/publish.ts @@ -111,11 +111,20 @@ export function usePublish(options: { isSending = true let status: mastodon.v1.Status - if (!draft.editingStatus) + if (!draft.editingStatus) { status = await client.v1.statuses.create(payload) + } - else - status = await client.v1.statuses.update(draft.editingStatus.id, payload) + else { + const updatePayload = { + ...payload, + mediaAttributes: draft.attachments.map(media => ({ + id: media.id, + description: media.description, + })), + } as mastodon.v1.UpdateStatusParams + status = await client.v1.statuses.update(draft.editingStatus.id, updatePayload) + } if (draft.params.inReplyToId) navigateToStatus({ status }) @@ -256,7 +265,8 @@ export function useUploadMediaAttachment(draftRef: Ref) { async function setDescription(att: mastodon.v1.MediaAttachment, description: string) { att.description = description - await client.v1.mediaAttachments.update(att.id, { description: att.description }) + if (!draft.editingStatus) + await client.v1.mediaAttachments.update(att.id, { description: att.description }) } function removeAttachment(index: number) {