Skip to content

Commit

Permalink
fix: copy message action type for message actions
Browse files Browse the repository at this point in the history
  • Loading branch information
khushal87 committed Sep 18, 2024
1 parent 684b298 commit db10ec9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
28 changes: 12 additions & 16 deletions package/src/components/Message/hooks/useMessageActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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: <Copy pathFill={grey} />,
title: t('Copy Message'),
}
: undefined;
const copyMessage: MessageActionType = {
action: () => {
setOverlay('none');
if (handleCopy) {
handleCopy(message);
}
handleCopyMessage();
},
actionType: 'copyMessage',
icon: <Copy pathFill={grey} />,
title: t('Copy Message'),
};

const deleteMessage: MessageActionType = {
action: () => {
Expand Down
5 changes: 3 additions & 2 deletions package/src/components/Message/utils/messageActions.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
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';

export type MessageActionsParams<
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
> = {
banUser: MessageActionType;
copyMessage: MessageActionType;
deleteMessage: MessageActionType;
dismissOverlay: () => void;
editMessage: MessageActionType;
Expand All @@ -32,7 +34,6 @@ export type MessageActionsParams<
* @deprecated use `banUser` instead.
*/
blockUser?: MessageActionType;
copyMessage?: MessageActionType;
} & Pick<MessageContextValue<StreamChatGenerics>, 'message' | 'isMyMessage'>;

export type MessageActionsProp<
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit db10ec9

Please sign in to comment.