PollsStore

object PollsStore

A non-persistent store singleton that handles polls and changes to their votes.

Types

Link copied to clipboard
data class VotesSnapshot(val count: Int, val voters: SortedSet<Long>, val hasFailed: Boolean = false, val isLoading: Boolean = false)

A snapshot of vote details for an answer.

Functions

Link copied to clipboard

Handles a gateway event by also dispatching it to the store thread

Link copied to clipboard
fun fetchDetails(channelId: Long, messageId: Long, answerId: Int)

Fetches detailed votes for a poll.

Link copied to clipboard
fun getResultFor(id: Long, finalised: Boolean): MessagePollResult?

Gets the stored votes for a message as MessagePollResult form.

Link copied to clipboard
fun handleMessageDelete(channelId: Long, messageId: Long)

Handles a message delete event, should only be called from StoreStream methods.

Link copied to clipboard
fun handleMessageUpdate(message: Message)
fun handleMessageUpdate(message: Message)

Handles a message create/update event, should only be called from StoreStream methods.

Link copied to clipboard
fun subscribe(channelId: Long, messageId: Long, onNext: (HashMap<Int, PollsStore.VotesSnapshot>?) -> Unit): Subscription

Subscribes to poll changes.

Link copied to clipboard
fun subscribeOnMain(channelId: Long, messageId: Long, onNext: (HashMap<Int, PollsStore.VotesSnapshot>?) -> Unit): Subscription

Subscribes to poll changes, and run the handler on the main UI thread.