RegularToot: supports polls
This commit is contained in:
parent
9bf957188c
commit
c85cffc03e
6 changed files with 408 additions and 2 deletions
|
@ -232,6 +232,40 @@ const TootList: Component<{
|
|||
openFullScreenToot(status, element, true);
|
||||
};
|
||||
|
||||
const vote = async ({
|
||||
status,
|
||||
votes,
|
||||
}: {
|
||||
status: mastodon.v1.Status;
|
||||
votes: readonly number[];
|
||||
}) => {
|
||||
const client = session()?.client;
|
||||
if (!client) return;
|
||||
|
||||
const toot = status.reblog ?? status;
|
||||
if (!toot.poll) return;
|
||||
|
||||
const npoll = await client.v1.polls.$select(toot.poll.id).votes.create({
|
||||
choices: votes,
|
||||
});
|
||||
|
||||
if (status.reblog) {
|
||||
props.onChangeToot(status.id, {
|
||||
...status,
|
||||
reblog: {
|
||||
...status.reblog,
|
||||
poll: npoll,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
props.onChangeToot(status.id, {
|
||||
...status,
|
||||
poll: npoll,
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return (
|
||||
<ErrorBoundary
|
||||
fallback={(err, reset) => {
|
||||
|
@ -272,6 +306,7 @@ const TootList: Component<{
|
|||
onRetoot={toggleBoost}
|
||||
onFavourite={toggleFavourite}
|
||||
onReply={reply}
|
||||
onVote={vote}
|
||||
onClick={[onItemClick, status()]}
|
||||
/>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue