Class ChannelListViewModel
-
- All Implemented Interfaces:
public final class ChannelListViewModel extends ViewModel
ViewModel class for ChannelListView. Responsible for keeping the channels list up to date. Can be bound to the view using ChannelListViewModel.bindView function.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classChannelListViewModel.StateDescribed the state of the list of channels.
public final classChannelListViewModel.PaginationStateDescribes the pagination state.
public classChannelListViewModel.ActionDescribes the available actions that can be taken.
public classChannelListViewModel.ErrorEventDescribes the actions that were taken.
-
Field Summary
Fields Modifier and Type Field Description public final static QuerySorter<Channel>DEFAULT_SORTprivate final LiveData<ChannelListViewModel.State>stateprivate final LiveData<Map<String, TypingEvent>>typingEventsprivate final LiveData<ChannelListViewModel.PaginationState>paginationStateprivate final LiveData<Event<ChannelListViewModel.ErrorEvent>>errorEvents
-
Constructor Summary
Constructors Constructor Description ChannelListViewModel(FilterObject filter, QuerySorter<Channel> sort, Integer limit, Integer messageLimit, Integer memberLimit, ChatEventHandlerFactory chatEventHandlerFactory, ChatClient chatClient, GlobalState globalState)
-
Method Summary
Modifier and Type Method Description final LiveData<ChannelListViewModel.State>getState()Represents the current state containing channel list information. final LiveData<Map<String, TypingEvent>>getTypingEvents()final LiveData<ChannelListViewModel.PaginationState>getPaginationState()Represents the current pagination state by containing information about the loading state and if we have reached the end of all available channels. final LiveData<Event<ChannelListViewModel.ErrorEvent>>getErrorEvents()Emits error events. final UnitonAction(ChannelListViewModel.Action action)Checks against available actions and creates side-effects accordingly. final UnitleaveChannel(Channel channel)Removes the current user from the channel. final UnitdeleteChannel(Channel channel)Deletes a channel. final UnithideChannel(Channel channel)Hides the given channel. final UnitmarkAllRead()Marks all of the channels as read. final UnitsetFilters(FilterObject filterObject)Allows us to change the filter based on our requirements. -
-
Constructor Detail
-
ChannelListViewModel
ChannelListViewModel(FilterObject filter, QuerySorter<Channel> sort, Integer limit, Integer messageLimit, Integer memberLimit, ChatEventHandlerFactory chatEventHandlerFactory, ChatClient chatClient, GlobalState globalState)
- Parameters:
filter- Filter for querying channels, should never be empty.sort- Defines the ordering of the channels.limit- The maximum number of channels to fetch.messageLimit- The number of messages to fetch for each channel.memberLimit- The number of members to fetch per channel.chatEventHandlerFactory- The instance of ChatEventHandlerFactory that will be used to create ChatEventHandler.chatClient- Entry point for all low-level operations.globalState- Global state of OfflinePlugin.
-
-
Method Detail
-
getState
final LiveData<ChannelListViewModel.State> getState()
Represents the current state containing channel list information.
-
getTypingEvents
final LiveData<Map<String, TypingEvent>> getTypingEvents()
-
getPaginationState
final LiveData<ChannelListViewModel.PaginationState> getPaginationState()
Represents the current pagination state by containing information about the loading state and if we have reached the end of all available channels.
-
getErrorEvents
final LiveData<Event<ChannelListViewModel.ErrorEvent>> getErrorEvents()
Emits error events.
-
onAction
final Unit onAction(ChannelListViewModel.Action action)
Checks against available actions and creates side-effects accordingly.
- Parameters:
action- The action to process.
-
leaveChannel
final Unit leaveChannel(Channel channel)
Removes the current user from the channel.
- Parameters:
channel- The channel that the current user will leave.
-
deleteChannel
final Unit deleteChannel(Channel channel)
Deletes a channel.
- Parameters:
channel- Channel to be deleted.
-
hideChannel
final Unit hideChannel(Channel channel)
Hides the given channel.
-
markAllRead
final Unit markAllRead()
Marks all of the channels as read.
-
setFilters
final Unit setFilters(FilterObject filterObject)
Allows us to change the filter based on our requirements.
- Parameters:
filterObject- The new filter to be applied to the query which lets us fetch different data.
-
-
-
-