import { MutationObserver, QueryKey } from '@tanstack/query-core'; import { WeavyType } from '../client/weavy'; import { PollMutationContextType, PollOptionType, PollParentTypes } from '../types/polls.types'; import { MsgType } from '../types/msg.types'; import { RealtimeGroupType, RealtimeOptionsType, RealtimeVoteEventType } from '../types/realtime.types'; export type MutatePollVariables = { optionId: number; parentType: PollParentTypes; parentId: number; }; export type PollMutationType = MutationObserver; export declare function getPollMutationOptions(weavy: WeavyType, appId: number | "feed", cacheKey: QueryKey): { mutationKey: readonly unknown[]; mutationFn: ({ optionId }: MutatePollVariables) => Promise; onMutate: (variables: MutatePollVariables) => PollMutationContextType; onSuccess: (data: MsgType, variables: MutatePollVariables) => Promise; }; export declare function getPollMutation(weavy: WeavyType, appId: number | "feed", cacheKey: QueryKey): PollMutationType; /** * Replaces the poll options of a cached post, message or comment with the ones the server has now. * * Used after a vote from someone else arrives. The event cannot be applied directly: its poll summary carries option * counts only, its option is just the one voted for (a single-choice poll also drops the voter's previous vote on * another option), and `has_voted` in it was rendered for the actor, not for this user. A fetch of the parent gives * every option with counts and the current user's own `has_voted`. * * @param weavy - The Weavy instance. * @param parentType - API path segment of the poll's parent type. * @param pollId - Id of the post, message or comment holding the poll. * @param cacheKey - Query key prefix of the list(s) holding the poll. */ export declare function refreshPollOptions(weavy: WeavyType, parentType: PollParentTypes, pollId: number, cacheKey: QueryKey): Promise; /** * Applies a `vote_added` / `vote_removed` event to the list cache of a poll host. * * Every host subscribed to the app group gets every vote event in it, whatever the poll's parent type, so a host * only acts when the poll is in its own cache; a post host ignores votes on message polls and so on. The voter's own * client refetches here too, as well as from the vote mutation: the second fetch is cheap and keeps the user's * other tabs in sync, which an actor check would break. * * @param weavy - The Weavy instance. * @param parentType - API path segment of the poll's parent type. * @param cacheKey - Query key prefix of the list(s) holding the poll. * @param realtimeEvent - The vote event. * @returns A promise that resolves when the cache is updated, or `undefined` when the event was not for this host. */ export declare function handleRealtimeVote(weavy: WeavyType, parentType: PollParentTypes, cacheKey: QueryKey, realtimeEvent: RealtimeVoteEventType): Promise | undefined; /** * Realtime subscription options for `vote_added` and `vote_removed` on the polls of a list. * * @param weavy - The Weavy instance. * @param group - Realtime group of the app holding the polls. * @param parentType - API path segment of the poll's parent type. * @param cacheKey - Query key prefix of the list(s) holding the polls. */ export declare function getRealtimeVoteOptions(weavy: WeavyType, group: RealtimeGroupType, parentType: PollParentTypes, cacheKey: QueryKey): RealtimeOptionsType[]; export declare function getVotesOptions(weavy: WeavyType, id: number): { queryKey: (string | number)[]; enabled: boolean; queryFn: () => Promise; }; //# sourceMappingURL=poll.d.ts.map