RegularToot: refactor, add env context

This commit is contained in:
thislight 2024-11-23 22:21:14 +08:00
parent cbdf5e667d
commit ad7db8e865
No known key found for this signature in database
GPG key ID: FCFE5192241CCD4E
5 changed files with 164 additions and 123 deletions

View file

@ -26,7 +26,13 @@ export type TootPollDialogPoll = {
initialVotes?: readonly number[];
multiple?: boolean;
onVote(votes: readonly number[]): void | Promise<void>;
onVote: [
(
status: mastodon.v1.Status,
votes: readonly number[],
) => void | Promise<void>,
mastodon.v1.Status,
];
onClose?: BottomSheetProps["onClose"] &
((reason: "cancel" | "success") => void);
};
@ -50,7 +56,7 @@ const TootPollDialog: Component<TootPollDialogPoll> = (props) => {
const sendVote = async () => {
setInProgress(true);
try {
await props.onVote(votes());
await props.onVote[0](props.onVote[1], votes());
} catch (reason) {
console.error(reason);
props.onClose?.("cancel");