From db10ec9898b4b9dbf33e52b8d7688dfa66291331 Mon Sep 17 00:00:00 2001 From: Khushal Agarwal Date: Wed, 18 Sep 2024 19:17:44 +0530 Subject: [PATCH] fix: copy message action type for message actions --- .../Message/hooks/useMessageActions.tsx | 28 ++++++++----------- .../Message/utils/messageActions.ts | 5 ++-- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/package/src/components/Message/hooks/useMessageActions.tsx b/package/src/components/Message/hooks/useMessageActions.tsx index 67de0464c7..3ee3ad8bf1 100644 --- a/package/src/components/Message/hooks/useMessageActions.tsx +++ b/package/src/components/Message/hooks/useMessageActions.tsx @@ -23,7 +23,6 @@ import { Unpin, UserDelete, } from '../../../icons'; -import { setClipboardString } from '../../../native'; import type { DefaultStreamChatGenerics } from '../../../types/types'; import { removeReservedFields } from '../../../utils/removeReservedFields'; import { MessageStatusTypes } from '../../../utils/utils'; @@ -175,21 +174,18 @@ export const useMessageActions = < title: message.user?.banned ? t('Unblock User') : t('Block User'), }; - const copyMessage: MessageActionType | undefined = - setClipboardString !== null - ? { - action: () => { - setOverlay('none'); - if (handleCopy) { - handleCopy(message); - } - handleCopyMessage(); - }, - actionType: 'copyMessage', - icon: , - title: t('Copy Message'), - } - : undefined; + const copyMessage: MessageActionType = { + action: () => { + setOverlay('none'); + if (handleCopy) { + handleCopy(message); + } + handleCopyMessage(); + }, + actionType: 'copyMessage', + icon: , + title: t('Copy Message'), + }; const deleteMessage: MessageActionType = { action: () => { diff --git a/package/src/components/Message/utils/messageActions.ts b/package/src/components/Message/utils/messageActions.ts index 16c1dd3f1d..96ca9ff1a1 100644 --- a/package/src/components/Message/utils/messageActions.ts +++ b/package/src/components/Message/utils/messageActions.ts @@ -1,5 +1,6 @@ import type { MessageContextValue } from '../../../contexts/messageContext/MessageContext'; import type { OwnCapabilitiesContextValue } from '../../../contexts/ownCapabilitiesContext/OwnCapabilitiesContext'; +import { setClipboardString } from '../../../native'; import type { DefaultStreamChatGenerics } from '../../../types/types'; import type { MessageActionType } from '../../MessageOverlay/MessageActionListItem'; @@ -7,6 +8,7 @@ export type MessageActionsParams< StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, > = { banUser: MessageActionType; + copyMessage: MessageActionType; deleteMessage: MessageActionType; dismissOverlay: () => void; editMessage: MessageActionType; @@ -32,7 +34,6 @@ export type MessageActionsParams< * @deprecated use `banUser` instead. */ blockUser?: MessageActionType; - copyMessage?: MessageActionType; } & Pick, 'message' | 'isMyMessage'>; export type MessageActionsProp< @@ -86,7 +87,7 @@ export const messageActions = < actions.push(editMessage); } - if (copyMessage !== undefined && message.text && !error) { + if (setClipboardString !== null && message.text && !error) { actions.push(copyMessage); }