mirror of https://github.com/tooot-app/app
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) => {
|
const mutationFunction = async (params: MutationVarsTimeline) => {
|
||||||
switch (params.type) {
|
switch (params.type) {
|
||||||
case 'updateStatusProperty':
|
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) {
|
switch (params.payload.type) {
|
||||||
case 'poll':
|
case 'poll':
|
||||||
return apiInstance<Mastodon.Poll>({
|
return apiInstance<Mastodon.Poll>({
|
||||||
method: params.payload.action === 'vote' ? 'post' : 'get',
|
method: params.payload.action === 'vote' ? 'post' : 'get',
|
||||||
url:
|
url: params.payload.action === 'vote' ? `polls/${pollId}/votes` : `polls/${pollId}`,
|
||||||
params.payload.action === 'vote'
|
|
||||||
? `polls/${params.status.poll?.id}/votes`
|
|
||||||
: `polls/${params.status.poll?.id}`,
|
|
||||||
...(params.payload.action === 'vote' && {
|
...(params.payload.action === 'vote' && {
|
||||||
body: {
|
body: {
|
||||||
choices: params.payload.options
|
choices: params.payload.options
|
||||||
|
@ -370,15 +379,6 @@ const mutationFunction = async (params: MutationVarsTimeline) => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
default:
|
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>({
|
return apiInstance<Mastodon.Status>({
|
||||||
method: 'post',
|
method: 'post',
|
||||||
url: `statuses/${tootId}/${params.payload.to ? '' : 'un'}${
|
url: `statuses/${tootId}/${params.payload.to ? '' : 'un'}${
|
||||||
|
|
Loading…
Reference in New Issue