Skip to content

Commit

Permalink
fix: respect useEmoji pref on reactions
Browse files Browse the repository at this point in the history
  • Loading branch information
yash-rajpal committed Apr 19, 2023
1 parent 8bc5bd1 commit 2ebae72
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions apps/meteor/app/reactions/client/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { MessageAction } from '../../ui-utils/client';
import { messageArgs } from '../../../client/lib/utils/messageArgs';
import { EmojiPicker } from '../../emoji/client';
import { roomCoordinator } from '../../../client/lib/rooms/roomCoordinator';
import { getUserPreference } from '../../utils/client';

Meteor.startup(function () {
MessageAction.addButton({
Expand All @@ -21,6 +22,10 @@ Meteor.startup(function () {
return false;
}

if (!user) {
return false;
}

if (!subscription) {
return false;
}
Expand All @@ -37,6 +42,12 @@ Meteor.startup(function () {
return false;
}

const useEmoji = getUserPreference(user._id, 'useEmoji');

if (!useEmoji) {
return false;
}

return true;
},
order: -2,
Expand Down
8 changes: 7 additions & 1 deletion apps/meteor/client/components/message/content/Reactions.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { IMessage } from '@rocket.chat/core-typings';
import { MessageReactions, MessageReactionAction } from '@rocket.chat/fuselage';
import { useUserPreference } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import React from 'react';

Expand All @@ -11,13 +12,18 @@ type ReactionsProps = {
message: IMessage;
};

const Reactions = ({ message }: ReactionsProps): ReactElement => {
const Reactions = ({ message }: ReactionsProps): ReactElement | null => {
const hasReacted = useUserHasReacted(message);
const filterReactions = useReactionsFilter(message);
const openEmojiPicker = useOpenEmojiPicker(message);
const useEmoji = useUserPreference('useEmoji');

const toggleReactionMutation = useToggleReactionMutation();

if (!useEmoji) {
return null;
}

return (
<MessageReactions>
{message.reactions &&
Expand Down

0 comments on commit 2ebae72

Please sign in to comment.