mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-05 15:00:30 +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,
|
onReplyClick,
|
||||||
onEditId,
|
onEditId,
|
||||||
onActiveStateChange,
|
onActiveStateChange,
|
||||||
|
closeMenu,
|
||||||
|
menuAnchor,
|
||||||
|
emojiBoardAnchor,
|
||||||
|
handleOpenEmojiBoard,
|
||||||
|
handleOpenMenu,
|
||||||
|
handleAddReactions,
|
||||||
|
setMenuAnchor,
|
||||||
|
setEmojiBoardAnchor,
|
||||||
}) {
|
}) {
|
||||||
const [menuAnchor, setMenuAnchor] = useState<RectCords>();
|
// const [menuAnchor, setMenuAnchor] = useState<RectCords>();
|
||||||
const [emojiBoardAnchor, setEmojiBoardAnchor] = useState<RectCords>();
|
// const [emojiBoardAnchor, setEmojiBoardAnchor] = useState<RectCords>();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onActiveStateChange?.(!!menuAnchor || !!emojiBoardAnchor);
|
onActiveStateChange?.(!!menuAnchor || !!emojiBoardAnchor);
|
||||||
|
|
@ -141,28 +149,6 @@ export function MessageOptionsMenu({
|
||||||
const eventId = mEvent.getId();
|
const eventId = mEvent.getId();
|
||||||
if (!eventId) return null;
|
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 (
|
return (
|
||||||
<div className={css.MessageOptionsBase}>
|
<div className={css.MessageOptionsBase}>
|
||||||
<Menu className={css.MessageOptionsBar} variant="SurfaceVariant">
|
<Menu className={css.MessageOptionsBar} variant="SurfaceVariant">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue