stream-chat-react
stream-chat-react copied to clipboard
feat: Move Channel state describing the MessageList state to the MessageList
Motivation
The following values describe the Channel
. Among them, there are many that actually do not belong to the Channel
, but rather to MessageList
(
value | pertains to |
---|---|
suppressAutoscroll: boolean; |
Main MessageList |
error?: Error | null; |
Channel |
hasMore?: boolean; |
Main MessageList |
hasMoreNewer?: boolean; |
Main MessageList |
highlightedMessageId?: string; |
Main MessageList |
loading?: boolean; |
Main MessageList |
loadingMore?: boolean; |
Main MessageList |
loadingMoreNewer?: boolean; |
Main MessageList |
members?: StreamChannelState<StreamChatGenerics>['members']; |
Channel |
messages?: StreamMessage<StreamChatGenerics>[]; |
Main MessageList |
pinnedMessages?: StreamMessage<StreamChatGenerics>[]; |
Channel |
quotedMessage?: StreamMessage<StreamChatGenerics>; |
Channel |
read?: StreamChannelState<StreamChatGenerics>['read']; |
Channel |
thread?: StreamMessage<StreamChatGenerics> | null; |
Channel |
threadHasMore?: boolean; |
Thread MessageList |
threadLoadingMore?: boolean; |
Thread MessageList |
threadMessages?: StreamMessage<StreamChatGenerics>[]; |
Thread MessageList |
threadSuppressAutoscroll?: boolean; |
Thread MessageList |
typing?: StreamChannelState<StreamChatGenerics>['typing']; |
Channel |
watcherCount?: number; |
Channel |
watchers?: StreamChannelState<StreamChatGenerics>['watchers']; |
Channel |
Problems
- As can be seen there is no parity between the Main
MessageList
and ThreadMessageList
. That leads to ThreadMessageList
not supporting some functionality, that is supported in the MainMessageList
. Or it may lead to unexpected behavior, when the state is shared by two message lists due to it being overwritten. - Having state unnecessarily high in the tree may lead to unwanted rerenders or more complex dependencies for component memoization and decrease the performance.
Proposed solution
Move message list related state into MessageList
component. That way there is no need to keep the thread vs main message list dichotomy and thus reduce code bloat.
Acceptance Criteria
- Parity of supported functionality btw. the Main
MessageList
and ThreadMessageList
.