mirror of
https://github.com/tooot-app/app
synced 2025-02-09 16:38:41 +01:00
Fix poll in "remote" toots not working
This commit is contained in:
parent
78b6834c3f
commit
88d4de98c2
@ -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'}${
|
||||
|
Loading…
x
Reference in New Issue
Block a user