diff --git a/frontend/src/ui/components/chat/MessageContextMenu.tsx b/frontend/src/ui/components/chat/MessageContextMenu.tsx index 696116e..fb3476f 100644 --- a/frontend/src/ui/components/chat/MessageContextMenu.tsx +++ b/frontend/src/ui/components/chat/MessageContextMenu.tsx @@ -108,27 +108,8 @@ export function MessageContextMenu({ window.removeEventListener('blur', handleWindowBlur); }; }, [isOpen, isClosing]); - - const handleAction = (action: string) => { - switch (action) { - case "reply": - onReply(message); - handleClose(); - break; - case "edit": - if (isAuthor) onEdit(message); - break; - case "delete": - if (isAuthor) { - onDelete(message); - handleClose(); - } - break; - } - onOpenChange(false); - }; - const handleClose = () => { + function handleClose() { setIsClosing(true); // Set appropriate closing animation based on opening animation const closingAnimation = animationClass.replace('entering', 'closing'); @@ -140,7 +121,44 @@ export function MessageContextMenu({ setIsClosing(false); setAnimationClass('entering'); // Reset for next opening }, 200); // Match the animation duration from _animations.scss - }; + } + + interface Action { + label: string; + icon: string; + onClick: () => void; + show: boolean; + } + + const actions: Action[] = [ + { + label: "Reply", + icon: "reply", + onClick: () => { + onReply(message); + handleClose(); + }, + show: true + }, + { + label: "Edit", + icon: "edit", + onClick: () => { + onEdit(message); + handleClose(); + }, + show: isAuthor + }, + { + label: "Delete", + icon: "delete", + onClick: () => { + onDelete(message); + handleClose(); + }, + show: isAuthor + }, + ]; return isOpen && (
e.stopPropagation()}> -
handleAction("reply")}> - reply - Ответить -
- {isAuthor && ( - <> -
handleAction("edit")}> - edit - Редактировать + {actions.map((action, i) => ( + action.show && ( +
+ {action.icon} + {action.label}
-
handleAction("delete")}> - delete - Удалить -
- - )} + ) + ))}
) }