Fix poll in "remote" toots not working

This commit is contained in:
xmflsct 2023-02-01 14:40:22 +01:00
parent 78b6834c3f
commit 88d4de98c2
1 changed files with 13 additions and 13 deletions

View File

@ -353,14 +353,23 @@ export type MutationVarsTimeline =
const mutationFunction = async (params: MutationVarsTimeline) => {
switch (params.type) {
case 'updateStatusProperty':
let tootId = params.status.id
let pollId = params.status.poll?.id
if (params.status._remote) {
const fetched = await searchLocalStatus(params.status.uri)
if (fetched) {
tootId = fetched.id
pollId = fetched.poll?.id
} else {
return Promise.reject('Fetching for remote toot failed')
}
}
switch (params.payload.type) {
case 'poll':
return apiInstance<Mastodon.Poll>({
method: params.payload.action === 'vote' ? 'post' : 'get',
url:
params.payload.action === 'vote'
? `polls/${params.status.poll?.id}/votes`
: `polls/${params.status.poll?.id}`,
url: params.payload.action === 'vote' ? `polls/${pollId}/votes` : `polls/${pollId}`,
...(params.payload.action === 'vote' && {
body: {
choices: params.payload.options
@ -370,15 +379,6 @@ const mutationFunction = async (params: MutationVarsTimeline) => {
})
})
default:
let tootId = params.status.id
if (params.status._remote) {
const fetched = await searchLocalStatus(params.status.uri)
if (fetched) {
tootId = fetched.id
} else {
return Promise.reject('Fetching for remote toot failed')
}
}
return apiInstance<Mastodon.Status>({
method: 'post',
url: `statuses/${tootId}/${params.payload.to ? '' : 'un'}${