feat: upgrade to masto.js v6 (#2530)

This commit is contained in:
patak 2024-01-09 09:56:15 +01:00 committed by GitHub
parent d8ea685803
commit 6c5bb83ac3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
62 changed files with 262 additions and 263 deletions

View file

@ -93,7 +93,7 @@ export function usePublish(options: {
language: draft.params.language || preferredLanguage,
poll,
...(isGlitchEdition.value ? { 'content-type': 'text/markdown' } : {}),
} as mastodon.v1.CreateStatusParams
} as mastodon.rest.v1.CreateStatusParams
if (process.dev) {
// eslint-disable-next-line no-console
@ -116,14 +116,13 @@ export function usePublish(options: {
}
else {
const updatePayload = {
status = await client.v1.statuses.$select(draft.editingStatus.id).update({
...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 })
@ -232,7 +231,7 @@ export function useUploadMediaAttachment(draftRef: Ref<Draft>) {
if (draft.attachments.length < limit) {
isExceedingAttachmentLimit = false
try {
const attachment = await client.v1.mediaAttachments.create({
const attachment = await client.v1.media.create({
file: await processFile(file),
})
draft.attachments.push(attachment)
@ -266,7 +265,7 @@ export function useUploadMediaAttachment(draftRef: Ref<Draft>) {
async function setDescription(att: mastodon.v1.MediaAttachment, description: string) {
att.description = description
if (!draft.editingStatus)
await client.v1.mediaAttachments.update(att.id, { description: att.description })
await client.v1.media.$select(att.id).update({ description: att.description })
}
function removeAttachment(index: number) {