Skip to content

Commit

Permalink
Merge pull request #25729 from huzaifa-99/24519-fix-emojis-on-invalid…
Browse files Browse the repository at this point in the history
…-phone-number-chats

Block emoji reaction on report actions of report with errors
  • Loading branch information
jasperhuangg committed Aug 23, 2023
2 parents f6e63e0 + c17a085 commit 4546dc0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
18 changes: 16 additions & 2 deletions src/components/Reactions/EmojiReactionBubble.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,36 @@ const propTypes = {
*/
hasUserReacted: PropTypes.bool,

/** We disable reacting with emojis on report actions that have errors */
shouldBlockReactions: PropTypes.bool,

...windowDimensionsPropTypes,
};

const defaultProps = {
count: 0,
onReactionListOpen: () => {},
isContextMenu: false,
shouldBlockReactions: false,

...withCurrentUserPersonalDetailsDefaultProps,
};

function EmojiReactionBubble(props) {
return (
<PressableWithSecondaryInteraction
style={({hovered, pressed}) => [styles.emojiReactionBubble, StyleUtils.getEmojiReactionBubbleStyle(hovered || pressed, props.hasUserReacted, props.isContextMenu)]}
onPress={props.onPress}
style={({hovered, pressed}) => [
styles.emojiReactionBubble,
StyleUtils.getEmojiReactionBubbleStyle(hovered || pressed, props.hasUserReacted, props.isContextMenu),
props.shouldBlockReactions && styles.cursorDisabled,
]}
onPress={() => {
if (props.shouldBlockReactions) {
return;
}

props.onPress();
}}
onLongPress={props.onReactionListOpen}
onSecondaryInteraction={props.onReactionListOpen}
ref={props.forwardedRef}
Expand Down
15 changes: 11 additions & 4 deletions src/components/Reactions/ReportActionItemEmojiReactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ const propTypes = {
*/
toggleReaction: PropTypes.func.isRequired,

/** We disable reacting with emojis on report actions that have errors */
shouldBlockReactions: PropTypes.bool,

...withCurrentUserPersonalDetailsPropTypes,
};

const defaultProps = {
...withCurrentUserPersonalDetailsDefaultProps,
emojiReactions: {},
shouldBlockReactions: false,
};

function ReportActionItemEmojiReactions(props) {
Expand Down Expand Up @@ -138,15 +142,18 @@ function ReportActionItemEmojiReactions(props) {
reactionUsers={reaction.reactionUsers}
hasUserReacted={reaction.hasUserReacted}
onReactionListOpen={reaction.onReactionListOpen}
shouldBlockReactions={props.shouldBlockReactions}
/>
</View>
</Tooltip>
);
})}
<AddReactionBubble
onSelectEmoji={props.toggleReaction}
reportAction={{reportActionID: props.reportActionID}}
/>
{!props.shouldBlockReactions && (
<AddReactionBubble
onSelectEmoji={props.toggleReaction}
reportAction={{reportActionID: props.reportActionID}}
/>
)}
</View>
)
);
Expand Down
11 changes: 7 additions & 4 deletions src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,10 @@ function ReportActionItem(props) {
/**
* Get the content of ReportActionItem
* @param {Boolean} hovered whether the ReportActionItem is hovered
* @param {Boolean} hasErrors whether the report action has any errors
* @returns {Object} child component(s)
*/
const renderItemContent = (hovered = false) => {
const renderItemContent = (hovered = false, hasErrors = false) => {
let children;
const originalMessage = lodashGet(props.action, 'originalMessage', {});

Expand Down Expand Up @@ -401,6 +402,7 @@ function ReportActionItem(props) {
<ReportActionItemEmojiReactions
reportActionID={props.action.reportActionID}
emojiReactions={props.emojiReactions}
shouldBlockReactions={hasErrors}
toggleReaction={(emoji) => {
if (Session.isAnonymousUser()) {
hideContextMenu(false);
Expand Down Expand Up @@ -436,10 +438,11 @@ function ReportActionItem(props) {
* Get ReportActionItem with a proper wrapper
* @param {Boolean} hovered whether the ReportActionItem is hovered
* @param {Boolean} isWhisper whether the ReportActionItem is a whisper
* @param {Boolean} hasErrors whether the report action has any errors
* @returns {Object} report action item
*/
const renderReportActionItem = (hovered, isWhisper) => {
const content = renderItemContent(hovered || isContextMenuActive);
const renderReportActionItem = (hovered, isWhisper, hasErrors) => {
const content = renderItemContent(hovered || isContextMenuActive, hasErrors);

if (props.draftMessage) {
return <ReportActionItemDraft>{content}</ReportActionItemDraft>;
Expand Down Expand Up @@ -592,7 +595,7 @@ function ReportActionItem(props) {
/>
</View>
)}
{renderReportActionItem(hovered, isWhisper)}
{renderReportActionItem(hovered, isWhisper, hasErrors)}
</OfflineWithFeedback>
</View>
</View>
Expand Down

0 comments on commit 4546dc0

Please sign in to comment.