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: deprecate messageReactions prop and use isMessageActionsVisible instead for messageActions #2676

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ messageActions={({
editMessage, // MessageAction | null;
error, // boolean;
flagMessage, // MessageAction | null;
isMessageActionsVisible, // boolean;
isMyMessage, // boolean;
isThreadMessage, // boolean;
message, // MessageType<At, Ch, Co, Ev, Me, Re, Us>;
messageReactions, // boolean;
reply, // MessageAction | null;
retry, // MessageAction | null;
threadReply, // MessageAction | null;
Expand Down
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
Loading