Skip to content

Commit

Permalink
fix: add attributes before status update (#2293)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sma11X committed Aug 2, 2023
1 parent 67d5d5c commit d975c6f
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions composables/masto/publish.ts
Expand Up @@ -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 })

Expand Down Expand Up @@ -256,7 +265,8 @@ export function useUploadMediaAttachment(draftRef: Ref<Draft>) {

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) {
Expand Down

0 comments on commit d975c6f

Please sign in to comment.