@cossistant/next
Version:
Next.js-ready SDK for building AI-powered support/chat widgets. Hooks + primitives, WS-driven, TypeScript-first. Next.js-ready, Tailwind optional.
57 lines (56 loc) • 1.91 kB
TypeScript
//#region ../react/src/hooks/private/use-grouped-messages.d.ts
type GroupedMessage = {
type: "message_group";
senderId: string;
senderType: SenderType;
items: TimelineItem[];
firstMessageId: string;
lastMessageId: string;
firstMessageTime: Date;
lastMessageTime: Date;
};
type TimelineEventItem = {
type: "timeline_event";
item: TimelineItem;
timestamp: Date;
};
type TimelineToolItem = {
type: "timeline_tool";
item: TimelineItem;
tool: string | null;
timestamp: Date;
};
type ConversationItem = GroupedMessage | TimelineEventItem | TimelineToolItem;
type UseGroupedMessagesOptions = {
items: TimelineItem[];
seenData?: ConversationSeen[];
currentViewerId?: string;
viewerType?: SenderType;
};
type UseGroupedMessagesProps = UseGroupedMessagesOptions;
/**
* Batches sequential timeline items from the same sender into groups and enriches
* them with read-receipt helpers so UIs can render conversation timelines with
* minimal effort. Seen data is normalised into quick lookup maps for unread
* indicators.
*/
declare const useGroupedMessages: ({
items,
seenData,
currentViewerId,
viewerType
}: UseGroupedMessagesOptions) => {
items: ConversationItem[];
seenByMap: Map<string, Set<string>>;
lastReadMessageMap: Map<string, string>;
unreadCountMap: Map<string, number>;
isMessageSeenByViewer: (messageId: string) => boolean;
getMessageSeenBy: (messageId: string) => readonly string[];
getLastReadMessageId: (userId: string) => string | undefined;
isLastReadMessage: (messageId: string, userId: string) => boolean;
getUnreadCount: (userId: string) => number;
hasUnreadAfter: (messageId: string, userId: string) => boolean;
};
//#endregion
export { ConversationItem, GroupedMessage, TimelineEventItem, TimelineToolItem, UseGroupedMessagesOptions, UseGroupedMessagesProps, useGroupedMessages };
//# sourceMappingURL=use-grouped-messages.d.ts.map