stream-chat-react
Version:
React components to create chat conversations or livestream style chat
51 lines • 2.15 kB
TypeScript
import type { LocalMessage } from 'stream-chat';
import type { MessageDeliveryStatus } from '../../ChannelListItem';
export type ChannelPreviewMessageType = 'text' | 'deleted' | 'error' | 'empty' | 'image' | 'giphy' | 'video' | 'voice' | 'file' | 'unsupported' | 'link' | 'location' | 'poll';
/**
* Delivery status of the last own message.
* Determines which delivery status icon to render in the preview.
*
* - `sending` — Clock icon
* - `sent` — Single checkmark icon
* - `delivered` — Double checkmark icon
* - `read` — Double checkmark icon (with distinct color)
*/
export type ChannelPreviewDeliveryStatus = 'sending' | 'sent' | 'delivered' | 'read';
export type LatestMessagePreviewData = {
/**
* The type of content being previewed.
* Use this to render the appropriate content-type icon.
*/
type: ChannelPreviewMessageType;
/**
* The preview text to display.
*/
text: string;
/**
* Delivery status of own message.
* Only present for own messages that are not in error state.
* Use this to render the delivery status icon (clock, checkmark, double checkmark).
*/
deliveryStatus?: ChannelPreviewDeliveryStatus;
/**
* Sender name prefix.
* - `"You"` (translated) for own messages
* - Sender's display name for incoming messages in group channels (>2 members)
* - `undefined` for incoming messages in direct conversations
*/
senderName?: string;
};
export type UseLatestMessagePreviewParams = {
/** The channel to generate preview for */
participantCount?: number;
/** The latest message in the channel */
latestMessage?: LocalMessage;
/**
* Delivery status from the `useMessageDeliveryStatus` hook.
* When provided, used to determine the delivery status icon.
* When omitted, delivery status icons are not shown.
*/
messageDeliveryStatus?: MessageDeliveryStatus;
};
export declare const useLatestMessagePreview: ({ latestMessage, messageDeliveryStatus, participantCount, }: UseLatestMessagePreviewParams) => LatestMessagePreviewData;
//# sourceMappingURL=useLatestMessagePreview.d.ts.map