stream-chat
Version:
JS SDK for the Stream Chat API
114 lines (113 loc) • 5.39 kB
TypeScript
import { AttachmentManager } from './attachmentManager';
import { CustomDataManager } from './CustomDataManager';
import { LinkPreviewsManager } from './linkPreviewsManager';
import { LocationComposer } from './LocationComposer';
import { PollComposer } from './pollComposer';
import { TextComposer } from './textComposer';
import type { MessageComposerMiddlewareValue } from './middleware';
import { MessageComposerMiddlewareExecutor, MessageDraftComposerMiddlewareExecutor } from './middleware';
import type { Unsubscribe } from '../store';
import { StateStore } from '../store';
import { generateUUIDv4 } from '../utils';
import { Channel } from '../channel';
import { Thread } from '../thread';
import type { ChannelAPIResponse, DraftResponse, LocalMessage, LocalMessageBase, MessageResponse } from '../types';
import { WithSubscriptions } from '../utils/WithSubscriptions';
import type { StreamChat } from '../client';
import type { MessageComposerConfig } from './configuration/types';
import type { DeepPartial } from '../types.utility';
type UnregisterSubscriptions = Unsubscribe;
export type LastComposerChange = {
draftUpdate: number | null;
stateUpdate: number;
};
export type EditingAuditState = {
lastChange: LastComposerChange;
};
export type LocalMessageWithLegacyThreadId = LocalMessage & {
legacyThreadId?: string;
};
export type CompositionContext = Channel | Thread | LocalMessageWithLegacyThreadId;
export type MessageComposerState = {
id: string;
draftId: string | null;
pollId: string | null;
quotedMessage: LocalMessageBase | null;
showReplyInChannel: boolean;
};
export type MessageComposerOptions = {
client: StreamChat;
compositionContext: CompositionContext;
composition?: DraftResponse | MessageResponse | LocalMessage;
config?: DeepPartial<MessageComposerConfig>;
};
export declare class MessageComposer extends WithSubscriptions {
readonly channel: Channel;
readonly state: StateStore<MessageComposerState>;
readonly editingAuditState: StateStore<EditingAuditState>;
readonly configState: StateStore<MessageComposerConfig>;
readonly compositionContext: CompositionContext;
readonly compositionMiddlewareExecutor: MessageComposerMiddlewareExecutor;
readonly draftCompositionMiddlewareExecutor: MessageDraftComposerMiddlewareExecutor;
editedMessage?: LocalMessage;
attachmentManager: AttachmentManager;
linkPreviewsManager: LinkPreviewsManager;
textComposer: TextComposer;
pollComposer: PollComposer;
locationComposer: LocationComposer;
customDataManager: CustomDataManager;
constructor({ composition, config, compositionContext, client, }: MessageComposerOptions);
static evaluateContextType(compositionContext: CompositionContext): "message" | "channel" | "thread" | "legacy_thread";
static constructTag(compositionContext: CompositionContext): `${ReturnType<typeof MessageComposer.evaluateContextType>}_${string}`;
static generateId: typeof generateUUIDv4;
get config(): MessageComposerConfig;
get contextType(): "message" | "channel" | "thread" | "legacy_thread";
get tag(): `message_${string}` | `channel_${string}` | `thread_${string}` | `legacy_thread_${string}`;
get threadId(): string | null;
get client(): StreamChat;
get id(): string;
get draftId(): string | null;
get lastChange(): LastComposerChange;
get quotedMessage(): LocalMessageBase | null;
get pollId(): string | null;
get showReplyInChannel(): boolean;
get hasSendableData(): boolean;
get compositionIsEmpty(): boolean;
get lastChangeOriginIsLocal(): boolean;
updateConfig(config: DeepPartial<MessageComposerConfig>): void;
refreshId: () => void;
initState: ({ composition, }?: {
composition?: DraftResponse | MessageResponse | LocalMessage;
}) => void;
initStateFromChannelResponse: (channelApiResponse: ChannelAPIResponse) => void;
initEditingAuditState: (composition?: DraftResponse | MessageResponse | LocalMessage) => EditingAuditState;
private logStateUpdateTimestamp;
private logDraftUpdateTimestamp;
registerDraftEventSubscriptions: () => () => void;
registerSubscriptions: () => UnregisterSubscriptions;
private subscribeMessageUpdated;
private subscribeMessageComposerSetupStateChange;
private subscribeMessageDeleted;
private subscribeDraftUpdated;
private subscribeDraftDeleted;
private subscribeTextComposerStateChanged;
private subscribeAttachmentManagerStateChanged;
private subscribeLocationComposerStateChanged;
private subscribeLinkPreviewsManagerStateChanged;
private subscribePollComposerStateChanged;
private subscribeCustomDataManagerStateChanged;
private subscribeMessageComposerStateChanged;
private subscribeMessageComposerConfigStateChanged;
setQuotedMessage: (quotedMessage: LocalMessage | null) => void;
toggleShowReplyInChannel: () => void;
clear: () => void;
restore: () => void;
compose: () => Promise<MessageComposerMiddlewareValue["state"] | undefined>;
composeDraft: () => Promise<import("..").MessageDraftComposerMiddlewareValueState | undefined>;
createDraft: () => Promise<void>;
deleteDraft: () => Promise<void>;
getDraft: () => Promise<void>;
createPoll: () => Promise<void>;
sendLocation: () => Promise<void>;
}
export {};