ChannelStateContext

The ChannelStateContext is a one of the context providers exposed in the Channel component and is consumable by all of the Channel children components. The context provides all the state properties and logic for a channel, and you can access these by calling the useChannelStateContext custom hook.

Basic Usage

Pull values from context with our custom hook:

const { channel, watchers } = useChannelStateContext();

Values

acceptedFiles

The value is forwarded to the context from the Channel component prop acceptedFiles.

Type
string[]

channel

The currently active StreamChat channel instance to be loaded into the Channel component and referenced by its children.

Type
object

channelCapabilities

The allowed channel permissions for the currently connected user.

Type
object

channelConfig

The configurations object for the currently active channel.

Type
object

channelUnreadUiState

The read state maintained for use by components representing channel unread state (for example UnreadMessagesSeparator, UnreadMessagesNotification).

PropertyTypeDescription
last_readDateDate when the channel was marked read the last time.
unread_messagesnumberThe count of unread messages in a given channel. Unread count refers only to foreign (not own) unread messages.
first_unread_message_idstring or undefinedThe ID of the message that was marked unread (notification.mark_unread event). The value is available only when a message is marked unread. Therefore, cannot be relied on to place unread messages UI.
last_read_message_idstring or undefinedThe ID of the message preceding the first unread message.
Type
ChannelUnreadUiState

dragAndDropWindow

The value is forwarded to the context from the Channel component prop dragAndDropWindow.

TypeDefault
booleanfalse

debounceURLEnrichmentMs:

Number of milliseconds to debounce firing the URL enrichment queries when typing. The default value is 1500(ms). See the guide Link Previews in Message Input for more.

TypeDefault
number1500

enrichURLForPreview

The value is forwarded to the context from the Channel component prop enrichURLForPreview.

TypeDefault
booleanfalse

error

Error object (if any) in loading the channel, otherwise null.

Type
object

findURLFn

Custom function to identify URLs in a string for later generation of link previews. See the guide Link Previews in Message Input for more.

Type
(text: string) => string[]

giphyVersion

The value is forwarded to the context from the Channel component prop giphyVersion.

TypeDefault
string’fixed_height’

imageAttachmentSizeHandler

The value is forwarded to the context from the Channel component prop imageAttachmentSizeHandler.

Type
(a: Attachment, e: HTMLElement) => ImageAttachmentConfiguration

hasMore

If the channel has more, older, messages to paginate through.

Type
boolean

hasMoreNewer

If the channel has more, newer, messages to paginate through.

Type
boolean

highlightedMessageId

Value is used internally for jump-to-message logic. Once the user “jumped” to the message, the message with the given ID is highlighted by manipulating its styles attribute.

Type
string

loading

Boolean for the channel loading state.

Type
boolean

loadingMore

Boolean for the channel loading more messages.

Type
boolean

loadingMoreNewer

Flag signalling whether newer messages are being loaded as the user scrolls down in the message list. Used internally by VirtualizedMessageList.

Type
boolean

maxNumberOfFiles

The value is forwarded to the context from the Channel component prop maxNumberOfFiles.

TypeDefault
number10

members

Members of this channel (members are permanent, watchers are users who are online right now).

Type
object[]

messages

Array of message objects.

Type
object[]

multipleUploads

The value is forwarded to the context from the Channel component prop multipleUploads.

TypeDefault
booleantrue

mutes

An array of muted users for a channel.

Type
object[]

notifications

Temporary notifications added to the MessageList on specific user/message actions.

Type
{id: string, text: string, type: ‘success’ | ‘error’}[]

onLinkPreviewDismissed

Custom function to react to link preview dismissal. See the guide Link Previews in Message Input for more.

Type
(linkPreview: LinkPreview) => void

pinnedMessages

The messages that are pinned in the channel.

Type
object[]

quotedMessage

An inline message reply to another message.

Type
object

read

The read state for each channel member.

Type
object

suppressAutoscroll

Flag signalling whether the scroll to the bottom is prevented. Used internally by MessageList and VirtualizedMessageList components.

Type
boolean

shouldGenerateVideoThumbnail

The value is forwarded to the context from the Channel component prop shouldGenerateVideoThumbnail.

Type
boolean

thread

The parent message for a thread, if there is one, otherwise null.

Type
object

threadHasMore

Boolean showing if there are more messages available in current active thread, set to false when the end of pagination is reached.

Type
boolean

threadLoadingMore

If the thread is currently loading more messages.

Type
boolean

threadMessages

Array of messages within a thread.

Type
object[]

threadSuppressAutoscroll

Flag signalling whether the scroll to the bottom is prevented in thread. Used internally by MessageList and VirtualizedMessageList components.

Type
boolean

videoAttachmentSizeHandler

The value is forwarded to the context from the Channel component prop videoAttachmentSizeHandler.

Type
(a: Attachment, e: HTMLElement) => VideoAttachmentConfiguration

watcherCount

The number of watchers on the channel.

Type
number

watchers

An array of users who are currently watching the channel.

Type
object[]

watcher_count

The number of watchers on the channel.

Type
number
© Getstream.io, Inc. All Rights Reserved.