Display the list of people who reacted

This commit is contained in:
2025-11-28 14:42:02 +01:00
parent 6c11979ef2
commit 799341f77c

View File

@@ -12,6 +12,7 @@ import {
DialogContentText, DialogContentText,
DialogTitle, DialogTitle,
TextField, TextField,
Tooltip,
Typography, Typography,
useTheme, useTheme,
} from "@mui/material"; } from "@mui/material";
@@ -150,7 +151,7 @@ function RoomMessage(p: {
const handleToggleReaction = async ( const handleToggleReaction = async (
key: string, key: string,
reaction: MessageReaction reaction: MessageReaction | undefined
) => { ) => {
try { try {
if (!reaction) if (!reaction)
@@ -268,10 +269,23 @@ function RoomMessage(p: {
{/* Reaction */} {/* Reaction */}
<Box sx={{ marginLeft: "50px" }}> <Box sx={{ marginLeft: "50px" }}>
{[...p.message.reactions.keys()].map((r) => { {[...p.message.reactions.keys()].map((r) => {
const userReaction = p.message.reactions const reactions = p.message.reactions.get(r)!;
.get(r)! const userReaction = reactions.find(
.find((r) => r.account === user.info.matrix_user_id); (r) => r.account === user.info.matrix_user_id
);
return ( return (
<Tooltip
enterDelay={50}
placement="top"
arrow
title={
<span style={{ whiteSpace: "pre-wrap" }}>
{reactions
.map((r) => p.users.get(r.account)?.display_name)
.join("\n")}
</span>
}
>
<Chip <Chip
size="small" size="small"
style={{ style={{
@@ -281,7 +295,9 @@ function RoomMessage(p: {
cursor: "pointer", cursor: "pointer",
}} }}
slotProps={{ slotProps={{
root: { onClick: () => handleToggleReaction(r, userReaction) }, root: {
onClick: () => handleToggleReaction(r, userReaction),
},
label: { style: { height: "2em" } }, label: { style: { height: "2em" } },
}} }}
color={userReaction !== undefined ? "success" : undefined} color={userReaction !== undefined ? "success" : undefined}
@@ -299,11 +315,12 @@ function RoomMessage(p: {
<EmojiIcon emojiKey={r} /> <EmojiIcon emojiKey={r} />
</div> </div>
<div style={{ height: "2em", marginLeft: "2px" }}> <div style={{ height: "2em", marginLeft: "2px" }}>
{p.message.reactions.get(r)?.length} {reactions.length}
</div> </div>
</span> </span>
} }
/> />
</Tooltip>
); );
})} })}
</Box> </Box>