Package com.aliucord.coreplugins.polls
Object PollsStore
-
- All Implemented Interfaces:
public class PollsStore
A non-persistent store singleton that handles polls and changes to their votes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final class
PollsStore.VotesSnapshot
A snapshot of vote details for an answer.
-
Field Summary
Fields Modifier and Type Field Description public final static PollsStore
INSTANCE
-
Method Summary
Modifier and Type Method Description final Unit
dispatchGatewayEvent(MessagePollVoteEvent event, Boolean isAdd)
Handles a gateway event by also dispatching it to the store thread final Unit
handleMessageUpdate(Message message)
Handles a message create/update event, should only be called from StoreStream methods. final Unit
handleMessageUpdate(Message message)
Handles a message create/update event, should only be called from StoreStream methods. final Unit
handleMessageDelete(Long channelId, Long messageId)
Handles a message delete event, should only be called from StoreStream methods. final Subscription
subscribeOnMain(Long channelId, Long messageId, Function1<HashMap<Integer, PollsStore.VotesSnapshot>, Unit> onNext)
Subscribes to poll changes, and run the handler on the main UI thread. final Subscription
subscribe(Long channelId, Long messageId, Function1<HashMap<Integer, PollsStore.VotesSnapshot>, Unit> onNext)
Subscribes to poll changes. final Unit
fetchDetails(Long channelId, Long messageId, Integer answerId)
Fetches detailed votes for a poll. final MessagePollResult
getResultFor(Long id, Boolean finalised)
Gets the stored votes for a message as MessagePollResult form. -
-
Method Detail
-
dispatchGatewayEvent
final Unit dispatchGatewayEvent(MessagePollVoteEvent event, Boolean isAdd)
Handles a gateway event by also dispatching it to the store thread
- Parameters:
event
- Message poll vote update gateway eventisAdd
- Whether the event is VOTE_ADD (true) or VOTE_REMOVE (false)
-
handleMessageUpdate
final Unit handleMessageUpdate(Message message)
Handles a message create/update event, should only be called from StoreStream methods.
Must be run on the store thread.
- Parameters:
message
- New message object
-
handleMessageUpdate
final Unit handleMessageUpdate(Message message)
Handles a message create/update event, should only be called from StoreStream methods.
Must be run on the store thread.
- Parameters:
message
- New message object
-
handleMessageDelete
final Unit handleMessageDelete(Long channelId, Long messageId)
Handles a message delete event, should only be called from StoreStream methods.
Must be run on the store thread.
- Parameters:
channelId
- Channel ID message was sent inmessageId
- Message ID
-
subscribeOnMain
final Subscription subscribeOnMain(Long channelId, Long messageId, Function1<HashMap<Integer, PollsStore.VotesSnapshot>, Unit> onNext)
Subscribes to poll changes, and run the handler on the main UI thread.
- Parameters:
channelId
- Channel ID of messagemessageId
- Message ID to subscribe toonNext
- Event handler, will run on the main thread
-
subscribe
final Subscription subscribe(Long channelId, Long messageId, Function1<HashMap<Integer, PollsStore.VotesSnapshot>, Unit> onNext)
Subscribes to poll changes.
- Parameters:
channelId
- Channel ID of messagemessageId
- Message ID to subscribe toonNext
- Event handler
-
fetchDetails
final Unit fetchDetails(Long channelId, Long messageId, Integer answerId)
Fetches detailed votes for a poll.
- Parameters:
channelId
- Channel ID of messagemessageId
- Message IDanswerId
- Answer ID to fetch detailed votes for
-
getResultFor
final MessagePollResult getResultFor(Long id, Boolean finalised)
Gets the stored votes for a message as MessagePollResult form.
- Parameters:
id
- Message idfinalised
- Whether or not the poll is finalised
-
-
-
-