stream-chat-react
Version:
React components to create chat conversations or livestream style chat
34 lines (33 loc) • 1.73 kB
TypeScript
import React from 'react';
import type { ReactNode } from 'react';
import type { UserResponse } from 'stream-chat';
import type { GroupStyle, RenderedMessage } from './utils';
import type { MessageProps } from '../Message';
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>;
/**
* 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;
/**
* 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' | 'groupStyles' | 'initialMessage' | 'lastReceivedId' | 'message' | 'readBy';
export declare function defaultRenderMessages({ channelUnreadUiState, components, customClasses, lastReceivedMessageId: lastReceivedId, messageGroupStyles, messages, readData, sharedMessageProps: messageProps, }: RenderMessagesOptions): React.JSX.Element[];
export {};