Object PollsStore

  • All Implemented Interfaces:

    
    public class PollsStore
    
                        

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

    • Constructor Detail

    • 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 event
        isAdd - 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 in
        messageId - 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 message
        messageId - Message ID to subscribe to
        onNext - Event handler, will run on the main thread
      • fetchDetails

         final Unit fetchDetails(Long channelId, Long messageId, Integer answerId)

        Fetches detailed votes for a poll.

        Parameters:
        channelId - Channel ID of message
        messageId - Message ID
        answerId - 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 id
        finalised - Whether or not the poll is finalised