stream-chat-react
Version:
React components to create chat conversations or livestream style chat
83 lines (82 loc) • 3.97 kB
TypeScript
import type { TFunction } from 'i18next';
import type { ChannelConfigWithInfo, LocalMessage, MessageResponse, Mute, StreamChat, UserResponse } from 'stream-chat';
import type { PinPermissions } from './hooks';
import type { MessageProps } from './types';
import type { ComponentContextValue, CustomMessageActions, MessageContextValue } from '../../context';
/**
* Following function validates a function which returns notification message.
* It validates if the first parameter is function and also if return value of function is string or no.
*/
export declare const validateAndGetMessage: <T extends unknown[]>(func: (...args: T) => unknown, args: T) => string | null;
/**
* Tell if the owner of the current message is muted
*/
export declare const isUserMuted: (message: LocalMessage, mutes?: Mute[]) => boolean;
export declare const MESSAGE_ACTIONS: {
delete: string;
edit: string;
flag: string;
markUnread: string;
mute: string;
pin: string;
quote: string;
react: string;
remindMe: string;
reply: string;
saveForLater: string;
};
export type MessageActionsArray<T extends string = string> = Array<keyof typeof MESSAGE_ACTIONS | T>;
export declare const defaultPinPermissions: PinPermissions;
export type Capabilities = {
canDelete?: boolean;
canEdit?: boolean;
canFlag?: boolean;
canMarkUnread?: boolean;
canMute?: boolean;
canPin?: boolean;
canQuote?: boolean;
canReact?: boolean;
canReply?: boolean;
};
export declare const getMessageActions: (actions: MessageActionsArray | boolean, { canDelete, canEdit, canFlag, canMarkUnread, canMute, canPin, canQuote, canReact, canReply, }: Capabilities, channelConfig?: ChannelConfigWithInfo) => MessageActionsArray<string>;
export declare const ACTIONS_NOT_WORKING_IN_THREAD: string[];
/**
* @deprecated use `shouldRenderMessageActions` instead
*/
export declare const showMessageActionsBox: (actions: MessageActionsArray<string>, inThread?: boolean | undefined) => boolean;
export declare const shouldRenderMessageActions: ({ customMessageActions, CustomMessageActionsList, inThread, messageActions, }: {
messageActions: MessageActionsArray;
customMessageActions?: CustomMessageActions;
CustomMessageActionsList?: ComponentContextValue['CustomMessageActionsList'];
inThread?: boolean;
}) => boolean;
export declare const areMessagePropsEqual: (prevProps: MessageProps & {
mutes?: Mute[];
showDetailedReactions?: boolean;
}, nextProps: MessageProps & {
mutes?: Mute[];
showDetailedReactions?: boolean;
}) => boolean;
export declare const areMessageUIPropsEqual: (prevProps: MessageContextValue & {
showDetailedReactions?: boolean;
}, nextProps: MessageContextValue & {
showDetailedReactions?: boolean;
}) => boolean;
export declare const messageHasReactions: (message?: LocalMessage) => boolean;
export declare const messageHasAttachments: (message?: LocalMessage) => boolean;
export declare const getImages: (message?: MessageResponse) => import("stream-chat").Attachment[];
export declare const getNonImageAttachments: (message?: MessageResponse) => import("stream-chat").Attachment[];
export interface TooltipUsernameMapper {
(user: UserResponse): string;
}
/**
* Default Tooltip Username mapper implementation.
*
* @param user the user.
*/
export declare const mapToUserNameOrId: TooltipUsernameMapper;
export declare const getReadByTooltipText: (users: UserResponse[], t: TFunction, client: StreamChat, tooltipUserNameMapper: TooltipUsernameMapper) => string;
export declare const isOnlyEmojis: (text?: string) => boolean;
export declare const isMessageBounced: (message: Pick<LocalMessage, 'type' | 'moderation' | 'moderation_details'>) => boolean;
export declare const isMessageBlocked: (message: Pick<LocalMessage, 'type' | 'moderation' | 'moderation_details'>) => boolean;
export declare const isMessageEdited: (message: Pick<LocalMessage, 'message_text_updated_at'>) => boolean;