UNPKG

stream-chat-react

Version:

React components to create chat conversations or livestream style chat

56 lines (55 loc) 3.2 kB
import type { PropsWithChildren } from 'react'; import React from 'react'; import type { LocalMessage, Message, MessageResponse, SendMessageOptions, UpdateMessageAPIResponse, UpdateMessageOptions } from 'stream-chat'; import type { ChannelStateReducerAction } from '../components/Channel/channelState'; import type { CustomMentionHandler } from '../components/Message/hooks/useMentionsHandler'; import type { ChannelUnreadUiState, UnknownType } from '../types/types'; export type MarkReadWrapperOptions = { /** * Signal, whether the `channelUnreadUiState` should be updated. * By default, the local state update is prevented when the Channel component is mounted. * This is in order to keep the UI indicating the original unread state, when the user opens a channel. */ updateChannelUiUnreadState?: boolean; }; export type RetrySendMessage = (message: LocalMessage) => Promise<void>; export type ChannelActionContextValue = { addNotification: (text: string, type: 'success' | 'error') => void; closeThread: (event?: React.BaseSyntheticEvent) => void; deleteMessage: (message: LocalMessage) => Promise<MessageResponse>; dispatch: React.Dispatch<ChannelStateReducerAction>; editMessage: (message: LocalMessage | MessageResponse, options?: UpdateMessageOptions) => Promise<UpdateMessageAPIResponse | void>; jumpToFirstUnreadMessage: (queryMessageLimit?: number, highlightDuration?: number) => Promise<void>; jumpToLatestMessage: () => Promise<void>; jumpToMessage: (messageId: string, limit?: number, highlightDuration?: number) => Promise<void>; loadMore: (limit?: number) => Promise<number>; loadMoreNewer: (limit?: number) => Promise<number>; loadMoreThread: () => Promise<void>; markRead: (options?: MarkReadWrapperOptions) => void; onMentionsClick: CustomMentionHandler; onMentionsHover: CustomMentionHandler; openThread: (message: LocalMessage, event?: React.BaseSyntheticEvent) => void; removeMessage: (message: LocalMessage) => void; retrySendMessage: RetrySendMessage; sendMessage: (params: { localMessage: LocalMessage; message: Message; options?: SendMessageOptions; }) => Promise<void>; setChannelUnreadUiState: React.Dispatch<React.SetStateAction<ChannelUnreadUiState | undefined>>; updateMessage: (message: MessageResponse | LocalMessage) => void; }; export declare const ChannelActionContext: React.Context<ChannelActionContextValue | undefined>; export declare const ChannelActionProvider: ({ children, value, }: PropsWithChildren<{ value: ChannelActionContextValue; }>) => React.JSX.Element; export declare const useChannelActionContext: (componentName?: string) => ChannelActionContextValue; /** * Typescript currently does not support partial inference, so if ChannelActionContext * typing is desired while using the HOC withChannelActionContext, the Props for the * wrapped component must be provided as the first generic. */ export declare const withChannelActionContext: <P extends UnknownType>(Component: React.ComponentType<P>) => { (props: Omit<P, keyof ChannelActionContextValue>): React.JSX.Element; displayName: string; };