mirror of
https://github.com/bitbaum/chatkit.git
synced 2026-12-04 12:27:33 +01:00
* feat(messenger): forward a message; pin and mute a conversation (0.41.0) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmsmMXvM981mcszxEA6 * chore: release as 0.42.0 (0.41.0 is the DictationField release) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmsmMXvM981mcszxEA6 --------- Co-authored-by: Claude <noreply@anthropic.com>
62 lines
3.3 KiB
TypeScript
62 lines
3.3 KiB
TypeScript
import { type MessengerAgent, type MessengerAttachment, type MessengerCard, type MessengerConversation, type MessengerMessage, type MessengerQuote, type MessengerTransport } from "../messenger.js";
|
|
import { type MessengerState, type MessengerThreadState } from "../messenger-state.js";
|
|
export type UseMessengerOptions = {
|
|
/** The id the viewer's own messages carry (`authorId`). */
|
|
viewerId: string;
|
|
transport: MessengerTransport;
|
|
agents?: readonly MessengerAgent[];
|
|
/**
|
|
* The open conversation, when the app keeps it (in the URL, so a link and
|
|
* the back button work). Leave it out and the Messenger keeps it itself.
|
|
*/
|
|
conversationId?: string | null;
|
|
onConversationChange?: (id: string | null) => void;
|
|
/** How long an agent may take before the thread says it has not answered. */
|
|
agentPatienceMs?: number;
|
|
};
|
|
export type MessengerController = {
|
|
state: MessengerState;
|
|
/** The open conversation, once the list (or a direct fetch) knows it. */
|
|
open: MessengerConversation | null;
|
|
thread: MessengerThreadState | null;
|
|
select: (id: string | null) => void;
|
|
reload: () => void;
|
|
reloadThread: () => void;
|
|
loadOlder: () => void;
|
|
/** Send to the open conversation. Resolves once it is on its way: a message
|
|
* that then fails stays in the thread, marked, with its own Try again. */
|
|
send: (body: string, attachments: readonly MessengerAttachment[], extra?: {
|
|
replyTo?: MessengerQuote;
|
|
card?: MessengerCard;
|
|
}) => Promise<boolean>;
|
|
/** Put the viewer's emoji on a message; the one they already have takes it
|
|
* off. Shown at once, taken back if the server refuses. */
|
|
react: (message: MessengerMessage, emoji: string) => Promise<boolean>;
|
|
retry: (message: MessengerMessage) => void;
|
|
discard: (message: MessengerMessage) => void;
|
|
edit: (message: MessengerMessage, body: string) => Promise<boolean>;
|
|
/** Delete for everyone (the viewer's own message): a tombstone stays. */
|
|
remove: (message: MessengerMessage) => Promise<boolean>;
|
|
/** Delete for me: gone from the viewer's view only. */
|
|
hide: (message: MessengerMessage) => Promise<boolean>;
|
|
/** The viewer typed something (throttled here). */
|
|
typed: () => void;
|
|
/** The viewer is looking at the newest message: move their read mark. */
|
|
seen: () => void;
|
|
/** Whether the thread is at its end, so an arriving message is seen at once. */
|
|
setFollowing: (following: boolean) => void;
|
|
start: (personIds: readonly string[]) => Promise<boolean>;
|
|
leave: (conversationId: string) => Promise<boolean>;
|
|
setPinned: (conversationId: string, pinned: boolean) => Promise<boolean>;
|
|
setMuted: (conversationId: string, muted: boolean) => Promise<boolean>;
|
|
forward: (message: MessengerMessage, conversationIds: readonly string[]) => Promise<boolean>;
|
|
dismissAgent: (agentId: string) => void;
|
|
};
|
|
/**
|
|
* The Messenger's behaviour, without its markup: what is loaded when, what an
|
|
* arriving message does, when the read mark moves, how a failed send is kept.
|
|
* `Messenger` is this plus the screen; an app with its own screen uses this
|
|
* and the pieces (`ConversationList`, `MessageThread`).
|
|
*/
|
|
export declare function useMessenger(options: UseMessengerOptions): MessengerController;
|
|
//# sourceMappingURL=use-messenger.d.ts.map
|