ChannelListViewModel

class ChannelListViewModel(filter: FilterObject? = null, sort: QuerySorter<Channel> = DEFAULT_SORT, limit: Int = 30, messageLimit: Int = 1, memberLimit: Int = 30, chatEventHandlerFactory: ChatEventHandlerFactory = ChatEventHandlerFactory(), chatClient: ChatClient = ChatClient.instance(), globalState: GlobalState = chatClient.globalState) : ViewModel

ViewModel class for ChannelListView. Responsible for keeping the channels list up to date. Can be bound to the view using ChannelListViewModel.bindView function.

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. Contains information such as the current user, connection state, unread counts etc.

Constructors

Link copied to clipboard
constructor(filter: FilterObject? = null, sort: QuerySorter<Channel> = DEFAULT_SORT, limit: Int = 30, messageLimit: Int = 1, memberLimit: Int = 30, chatEventHandlerFactory: ChatEventHandlerFactory = ChatEventHandlerFactory(), chatClient: ChatClient = ChatClient.instance(), globalState: GlobalState = chatClient.globalState)

Types

Link copied to clipboard
sealed class Action

Describes the available actions that can be taken.

Link copied to clipboard
object Companion
Link copied to clipboard
sealed class ErrorEvent

Describes the actions that were taken.

Link copied to clipboard
data class PaginationState(val loadingMore: Boolean = false, val endOfChannels: Boolean = false)

Describes the pagination state.

Link copied to clipboard
data class State(val isLoading: Boolean, val channels: List<Channel>)

Described the state of the list of channels.

Properties

Link copied to clipboard
Link copied to clipboard

Represents the current pagination state by containing information about the loading state and if we have reached the end of all available channels.

Link copied to clipboard

Represents the current state containing channel list information.

Link copied to clipboard

Updates about currently typing users in active channels.

Functions

Link copied to clipboard
fun deleteChannel(channel: Channel)

Deletes a channel.

Link copied to clipboard
fun hideChannel(channel: Channel)

Hides the given channel.

Link copied to clipboard
fun leaveChannel(channel: Channel)

Removes the current user from the channel.

Link copied to clipboard

Marks all of the channels as read.

Link copied to clipboard

Checks against available actions and creates side-effects accordingly.

Link copied to clipboard
fun setFilters(filterObject: FilterObject)

Allows us to change the filter based on our requirements.

Inherited functions

Link copied to clipboard
open fun addCloseable(closeable: AutoCloseable)
fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard
@JvmName(name = "bind")
fun ChannelListViewModel.bindView(view: ChannelListView, lifecycleOwner: LifecycleOwner)

Binds ChannelListView with ChannelListViewModel, updating the view's state based on data provided by the ViewModel, and propagating view events to the ViewModel as needed.

Link copied to clipboard