Skip to content

Commit

Permalink
fix: deprecate messageReactions prop and use isMessageActionsVisible …
Browse files Browse the repository at this point in the history
…instead for messageActions
  • Loading branch information
khushal87 committed Sep 18, 2024
1 parent 3497bcb commit 910c5a3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
11 changes: 8 additions & 3 deletions package/src/components/Message/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ export type MessageActionHandlers<
pinMessage: () => Promise<void>;
quotedReply: () => void;
resendMessage: () => Promise<void>;
/**
* @deprecated
* TODO: This seems useless for the action handlers here so can be removed.
*/
showMessageOverlay: () => void;
toggleBanUser: () => Promise<void>;
toggleMuteUser: () => Promise<void>;
Expand Down Expand Up @@ -557,7 +561,7 @@ const MessageWithContext = <

const { userLanguage } = useTranslationContext();

const showMessageOverlay = async (messageReactions = false, error = errorOrFailed) => {
const showMessageOverlay = async (isMessageActionsVisible = false, error = errorOrFailed) => {
await dismissKeyboard();

const isThreadMessage = threadList || !!message.parent_id;
Expand All @@ -576,10 +580,11 @@ const MessageWithContext = <
editMessage,
error,
flagMessage,
isMessageActionsVisible,
isMyMessage,
isThreadMessage,
message,
messageReactions,
messageReactions: isMessageActionsVisible === false,
muteUser,
ownCapabilities,
pinMessage,
Expand All @@ -600,7 +605,7 @@ const MessageWithContext = <
message,
messageActions: messageActions?.filter(Boolean) as MessageActionListItemProps[] | undefined,
messageContext: { ...messageContext, preventPress: true },
messageReactionTitle: !error && messageReactions ? t('Message Reactions') : undefined,
messageReactionTitle: !error && !isMessageActionsVisible ? t('Message Reactions') : undefined,
messagesContext: { ...messagesContext, messageContentOrder },
onlyEmojis,
otherAttachments: attachments.other,
Expand Down
12 changes: 10 additions & 2 deletions package/src/components/Message/utils/messageActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ export type MessageActionsParams<
editMessage: MessageActionType;
error: boolean | Error;
flagMessage: MessageActionType;
/**
* Determines if the message actions are visible.
*/
isMessageActionsVisible: boolean;
isThreadMessage: boolean;
/**
* @deprecated use `isMessageActionsVisible` instead.
*/
messageReactions: boolean;
muteUser: MessageActionType;
ownCapabilities: OwnCapabilitiesContextValue;
Expand Down Expand Up @@ -42,6 +49,7 @@ export const messageActions = <
editMessage,
error,
flagMessage,
isMessageActionsVisible,
isMyMessage,
isThreadMessage,
message,
Expand All @@ -53,8 +61,8 @@ export const messageActions = <
threadReply,
unpinMessage,
}: MessageActionsParams<StreamChatGenerics>) => {
if (messageReactions) {
return undefined;
if (messageReactions || !isMessageActionsVisible) {
return [];
}

const actions: Array<MessageActionType> = [];
Expand Down
2 changes: 1 addition & 1 deletion package/src/contexts/messageContext/MessageContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export type MessageContextValue<
reactions: ReactionSummary[];
/** React set state function to set the state of `isEditedMessageOpen` */
setIsEditedMessageOpen: React.Dispatch<React.SetStateAction<boolean>>;
showMessageOverlay: (messageReactions?: boolean, error?: boolean) => void;
showMessageOverlay: (isMessageActionsVisible?: boolean, error?: boolean) => void;
showMessageStatus: boolean;
/** Whether or not the Message is part of a Thread */
threadList: boolean;
Expand Down
7 changes: 7 additions & 0 deletions package/src/contexts/overlayContext/OverlayContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ export type OverlayProviderProps<
isMyMessage?: boolean;
isThreadMessage?: boolean;
message?: MessageType<StreamChatGenerics>;
/**
* @deprecated use the following instead:
* messageActions={(params) => {
* const actions = messageActions({ ...params, isMessageActionsVisible: false });
* return actions;
* }}
*/
messageReactions?: boolean;
messageTextNumberOfLines?: number;
numberOfImageGalleryGridColumns?: number;
Expand Down

0 comments on commit 910c5a3

Please sign in to comment.