UNPKG

stream-chat-react

Version:

React components to create chat conversations or livestream style chat

37 lines (36 loc) 1.97 kB
import type { ReactNode } from 'react'; import React from 'react'; import type { GroupStyle, RenderedMessage } from './utils'; import type { MessageProps } from '../Message'; import type { LocalMessage, UserResponse } from 'stream-chat'; import type { ComponentContextValue, CustomClasses } from '../../context'; import type { ChannelUnreadUiState } from '../../types'; export interface RenderMessagesOptions { components: ComponentContextValue; lastReceivedMessageId: string | null; messageGroupStyles: Record<string, GroupStyle>; messages: Array<RenderedMessage>; ownMessagesDeliveredToOthers: Record<string, UserResponse[]>; /** * Object mapping message IDs of own messages to the users who read those messages. */ readData: Record<string, Array<UserResponse>>; /** * Props forwarded to the Message component. */ sharedMessageProps: SharedMessageProps; /** Latest own message in currently displayed message set. */ lastOwnMessage?: LocalMessage; /** * Current user's channel read state used to render components reflecting unread state. * It does not reflect the back-end state if a channel is marked read on mount. * This is in order to keep the unread UI when an unread channel is open. */ channelUnreadUiState?: ChannelUnreadUiState; customClasses?: CustomClasses; } export type SharedMessageProps = Omit<MessageProps, MessagePropsToOmit>; export type MessageRenderer = (options: RenderMessagesOptions) => Array<ReactNode>; type MessagePropsToOmit = 'channel' | 'deliveredTo' | 'groupStyles' | 'initialMessage' | 'lastReceivedId' | 'message' | 'readBy'; export declare function defaultRenderMessages({ channelUnreadUiState, components, customClasses, lastOwnMessage, lastReceivedMessageId: lastReceivedId, messageGroupStyles, messages, ownMessagesDeliveredToOthers, readData, sharedMessageProps: messageProps, }: RenderMessagesOptions): React.JSX.Element[]; export {};