import type { PropsWithChildren } from 'react'; import React from 'react'; import type { DeleteMessageOptions, LocalMessage, ReactionResponse, SortParamRequest, UserResponse } from 'stream-chat'; import type { ActionHandlerReturnType } from '../components/Message/hooks/useActionHandler'; import type { ReactEventHandler } from '../components/Message/types'; import type { GroupStyle } from '../components/MessageList/utils'; import type { ReactionsComparator, ReactionType } from '../components/Reactions/types'; import type { RenderTextFunction } from '../components/Message/renderText'; export type MessageContextValue = { /** Sends a message action. A returned message is ingested; otherwise the local one is removed. */ handleAction: ActionHandlerReturnType; handleDelete: (options?: DeleteMessageOptions) => Promise | void; /** Fetches the message reactions, optionally of one type and sorted. */ handleFetchReactions: (reactionType?: ReactionType, sort?: SortParamRequest[]) => Promise>; handleFlag: ReactEventHandler; /** Marks the message and the messages that follow it as unread. */ handleMarkUnread: ReactEventHandler; handleMute: ReactEventHandler; /** Opens the message's thread: the `openThread` prop of `Message`, else ChatView navigation. */ handleOpenThread: ReactEventHandler; /** Pins or unpins the message. Rejects with the request's error when it fails, after rolling back. */ handlePin: ReactEventHandler; handleReaction: (reactionType: string, event: React.BaseSyntheticEvent) => Promise; handleRetry: (message: LocalMessage) => Promise | void; isMyMessage: () => boolean; message: LocalMessage; /** Click handler for an @mention in the message; `undefined` when no `onMentionsClick` handler is set. */ onMentionsClickMessage?: ReactEventHandler; /** Hover handler for an @mention in the message; `undefined` when no `onMentionsHover` handler is set. */ onMentionsHoverMessage?: ReactEventHandler; /** Click handler for the user who posted the message. */ onUserClick: ReactEventHandler; /** Hover handler for the user who posted the message. */ onUserHover: ReactEventHandler; /** * Keeps the message list scrolled to the bottom when the scroll height grows, e.g. when an * element appears below the last message. Only used in the `VirtualizedMessageList`. */ autoscrollToBottom?: () => void; /** If true, picking a reaction in the `ReactionSelector` closes the selector. */ closeReactionSelectorOnClick?: boolean; /** Users that have confirmed the message delivery to their device. */ deliveredTo?: UserResponse[]; /** Overrides the date formatting. Receives the original date and returns a string. */ formatDate?: (date: Date) => string; /** * The message's position in its group of consecutive messages from one user: `top`, `middle`, * `bottom` or `single`. The message lists add it to the list item as `str-chat__li--