@medipha/chat 1.0.16 → 1.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ import { JSONContent } from '@tiptap/core';
2
+ type DraftMap = Record<string, JSONContent>;
3
+ interface DraftState {
4
+ draftByConversation: DraftMap;
5
+ /** Stores (or, with `null`, discards) the unsent composer content for one conversation. */
6
+ setDraft: (conversationId: string, doc: JSONContent | null) => void;
7
+ }
8
+ /** Flattens a draft doc to the one-line plain text the sidebar row previews. Mention nodes
9
+ * carry their display name in attrs rather than as a text child, so they need their own
10
+ * branch or an "@ai đó" draft would preview as an empty string. */
11
+ export declare function getDraftText(doc: JSONContent | undefined): string;
12
+ /** Writes the pending draft snapshot out immediately — call before the tab goes away, or
13
+ * before handing the store over to a different account. */
14
+ export declare function flushDrafts(): void;
15
+ /**
16
+ * Points the store at one account's drafts: flushes whatever the previous account still had
17
+ * pending, then loads that user's own set. Called once the session's user id is known (see
18
+ * ChatBootstrap) — signing in as someone else on the same browser therefore swaps the whole
19
+ * map rather than leaking the first account's unsent text into the second's sidebar.
20
+ */
21
+ export declare function setDraftUser(userId: string | null): void;
22
+ /**
23
+ * Unsent composer content, kept per conversation so switching threads (or reloading) and
24
+ * coming back restores what was being typed — Zalo/Messenger behaviour. Scoped to the
25
+ * signed-in user and mirrored to localStorage; a draft is dropped the moment its message is
26
+ * actually sent.
27
+ */
28
+ export declare const useDraftStore: import('zustand').UseBoundStore<import('zustand').StoreApi<DraftState>>;
29
+ export {};
@@ -0,0 +1,13 @@
1
+ interface TypingState {
2
+ /** conversationId -> display names currently typing there, most recent first. */
3
+ namesByConversation: Record<string, string[]>;
4
+ /** Replaces the typer list for one conversation; an empty list drops the key entirely. */
5
+ setTypingNames: (conversationId: string, names: string[]) => void;
6
+ clearConversation: (conversationId: string) => void;
7
+ }
8
+ /** Mirrors the open conversation's typing state so the sidebar row can show "Đang nhập..."
9
+ * the same way Zalo/Messenger do. It is fed by useTypingIndicator (the single owner of the
10
+ * typing timers) rather than by its own socket subscription — which also means it only
11
+ * ever covers the conversation currently open, since the socket joins that room alone. */
12
+ export declare const useTypingStore: import('zustand').UseBoundStore<import('zustand').StoreApi<TypingState>>;
13
+ export {};