Message Context Menu: Fix multiple reactions from a single user (#2198)
This commit is contained in:
parent
0782cb1a6b
commit
6ebadcec4d
@ -158,22 +158,26 @@ const ReactorListModal: FC<OwnProps & StateProps> = ({
|
||||
items={viewportIds}
|
||||
onLoadMore={getMore}
|
||||
>
|
||||
{viewportIds?.map(
|
||||
{viewportIds?.flatMap(
|
||||
(userId) => {
|
||||
const user = usersById[userId];
|
||||
const reaction = reactors?.reactions.find((l) => l.userId === userId)?.reaction;
|
||||
return (
|
||||
<ListItem
|
||||
key={userId}
|
||||
className="chat-item-clickable reactors-list-item"
|
||||
// eslint-disable-next-line react/jsx-no-bind
|
||||
onClick={() => handleClick(userId)}
|
||||
>
|
||||
<Avatar user={user} size="small" animationLevel={animationLevel} withVideo />
|
||||
<FullNameTitle peer={user} withEmojiStatus />
|
||||
{reaction && <ReactionStaticEmoji className="reactors-list-emoji" reaction={reaction} />}
|
||||
</ListItem>
|
||||
);
|
||||
const userReactions = reactors?.reactions.filter((l) => l.userId === userId);
|
||||
const items: React.ReactNode[] = [];
|
||||
userReactions?.forEach((r) => {
|
||||
items.push(
|
||||
<ListItem
|
||||
key={`${userId}-${r.reaction}`}
|
||||
className="chat-item-clickable reactors-list-item"
|
||||
// eslint-disable-next-line react/jsx-no-bind
|
||||
onClick={() => handleClick(userId)}
|
||||
>
|
||||
<Avatar user={user} size="small" animationLevel={animationLevel} withVideo />
|
||||
<FullNameTitle peer={user} withEmojiStatus />
|
||||
{r.reaction && <ReactionStaticEmoji className="reactors-list-emoji" reaction={r.reaction} />}
|
||||
</ListItem>,
|
||||
);
|
||||
});
|
||||
return items;
|
||||
},
|
||||
)}
|
||||
</InfiniteScroll>
|
||||
|
||||
@ -203,7 +203,9 @@ const ContextMenuContainer: FC<OwnProps & StateProps> = ({
|
||||
// No need for expensive global updates on users, so we avoid them
|
||||
const usersById = getGlobal().users.byId;
|
||||
|
||||
return message.reactions?.recentReactions?.slice(0, 3).map(({ userId }) => usersById[userId]).filter(Boolean);
|
||||
const uniqueReactors = new Set(message.reactions?.recentReactions?.map(({ userId }) => usersById[userId]));
|
||||
|
||||
return Array.from(uniqueReactors).filter(Boolean).slice(0, 3);
|
||||
}
|
||||
|
||||
if (!message.seenByUserIds) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user