diff --git a/src/components/Chat/MessageItem.tsx b/src/components/Chat/MessageItem.tsx index d669c7f..b711116 100644 --- a/src/components/Chat/MessageItem.tsx +++ b/src/components/Chat/MessageItem.tsx @@ -1,8 +1,8 @@ import { Message } from "@chatscope/chat-ui-kit-react"; -import React, { useEffect } from "react"; +import React, { useEffect, useState } from "react"; import { useInView } from "react-intersection-observer"; import { MessageDisplay } from "./MessageDisplay"; -import { Avatar, Box, ButtonBase, Typography } from "@mui/material"; +import { Avatar, Box, Button, ButtonBase, List, ListItem, ListItemText, Popover, Typography } from "@mui/material"; import { formatTimestamp } from "../../utils/time"; import { getBaseApi } from "../../background"; import { getBaseApiReact } from "../../App"; @@ -35,6 +35,8 @@ export const MessageItem = ({ lastSignature, onEdit }) => { + const [anchorEl, setAnchorEl] = useState(null); + const [selectedReaction, setSelectedReaction] = useState(null); const { ref, inView } = useInView({ threshold: 0.7, // Fully visible triggerOnce: false, // Only trigger once when it becomes visible @@ -243,18 +245,16 @@ export const MessageItem = ({ // const myReaction = reactions if(numberOfReactions === 0) return null return ( - { - if(reactions[reaction] && reactions[reaction]?.find((item)=> item?.sender === myAddress)){ - handleReaction(reaction, message, false) - } else { - handleReaction(reaction, message, true) - } - }}> + }} onClick={(event) => { + event.stopPropagation(); // Prevent event bubbling + setAnchorEl(event.currentTarget); + setSelectedReaction(reaction); + }}>
{reaction}
{numberOfReactions > 1 && ( + {selectedReaction && ( + { + setAnchorEl(null); + setSelectedReaction(null); + }} + anchorOrigin={{ + vertical: "top", + horizontal: "center", + }} + transformOrigin={{ + vertical: "bottom", + horizontal: "center", + }} + PaperProps={{ + style: { + backgroundColor: "#232428", + color: "white", + }, + }} + > + + + People who reacted with {selectedReaction} + + + {reactions[selectedReaction]?.map((reactionItem) => ( + + + + ))} + + + + + )}