mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-04 22:40:29 +03:00
Pull out the dupes and just pass them parameter bloat is fine here as it shouldn't grow too much more
This commit is contained in:
parent
df7b71b768
commit
770732beb4
1 changed files with 10 additions and 24 deletions
|
|
@ -130,9 +130,17 @@ export function MessageOptionsMenu({
|
|||
onReplyClick,
|
||||
onEditId,
|
||||
onActiveStateChange,
|
||||
closeMenu,
|
||||
menuAnchor,
|
||||
emojiBoardAnchor,
|
||||
handleOpenEmojiBoard,
|
||||
handleOpenMenu,
|
||||
handleAddReactions,
|
||||
setMenuAnchor,
|
||||
setEmojiBoardAnchor,
|
||||
}) {
|
||||
const [menuAnchor, setMenuAnchor] = useState<RectCords>();
|
||||
const [emojiBoardAnchor, setEmojiBoardAnchor] = useState<RectCords>();
|
||||
// const [menuAnchor, setMenuAnchor] = useState<RectCords>();
|
||||
// const [emojiBoardAnchor, setEmojiBoardAnchor] = useState<RectCords>();
|
||||
|
||||
useEffect(() => {
|
||||
onActiveStateChange?.(!!menuAnchor || !!emojiBoardAnchor);
|
||||
|
|
@ -141,28 +149,6 @@ export function MessageOptionsMenu({
|
|||
const eventId = mEvent.getId();
|
||||
if (!eventId) return null;
|
||||
|
||||
const closeMenu = () => {
|
||||
setMenuAnchor(undefined);
|
||||
};
|
||||
|
||||
const handleOpenMenu: MouseEventHandler<HTMLButtonElement> = (evt) => {
|
||||
const target = evt.currentTarget.parentElement?.parentElement ?? evt.currentTarget;
|
||||
setMenuAnchor(target.getBoundingClientRect());
|
||||
};
|
||||
|
||||
const handleOpenEmojiBoard: MouseEventHandler<HTMLButtonElement> = (evt) => {
|
||||
const target = evt.currentTarget.parentElement?.parentElement ?? evt.currentTarget;
|
||||
setEmojiBoardAnchor(target.getBoundingClientRect());
|
||||
};
|
||||
|
||||
const handleAddReactions: MouseEventHandler<HTMLButtonElement> = () => {
|
||||
const rect = menuAnchor;
|
||||
closeMenu();
|
||||
// Use a timeout to allow the first menu to close before opening the next
|
||||
setTimeout(() => {
|
||||
setEmojiBoardAnchor(rect);
|
||||
}, 100);
|
||||
};
|
||||
return (
|
||||
<div className={css.MessageOptionsBase}>
|
||||
<Menu className={css.MessageOptionsBar} variant="SurfaceVariant">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue