Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: copy message action type for message actions #2679

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
khushal87 marked this conversation as resolved.
Show resolved Hide resolved
actions.push(copyMessage);
}

Expand Down
Loading