Add quick reactions

This commit is contained in:
2025-11-28 12:05:29 +01:00
parent f5b16b6ce4
commit 9f0bc3303c

View File

@@ -219,6 +219,10 @@ function RoomMessage(p: {
right: "0px",
}}
>
{/* Common reactions */}
<ReactionButton {...p} emojiKey="👍" /> {/* 👍 */}
<ReactionButton {...p} emojiKey="♥️" /> {/* ♥️ */}
<ReactionButton {...p} emojiKey="😂" /> {/* 😂 */}
{/* Add reaction */}
<Button onClick={handleAddReaction}>
<AddReactionIcon />
@@ -291,3 +295,31 @@ function RoomMessage(p: {
</>
);
}
function ReactionButton(p: {
room: Room;
message: Message;
emojiKey: string;
}): React.ReactElement {
const alert = useAlert();
const user = useUserInfo();
const sendEmoji = async () => {
try {
await MatrixApiEvent.ReactToEvent(p.room, p.message.event_id, p.emojiKey);
} catch (e) {
console.error("Failed to send reaction!", e);
alert(`Failed to send reaction! ${e}`);
}
};
// Do not offer to react to existing reactions
if (
p.message.reactions.find(
(r) => r.key === p.emojiKey && r.account === user.info.matrix_user_id
) !== undefined
)
return <></>;
return <Button onClick={sendEmoji}>{p.emojiKey}</Button>;
}