diff --git a/web/utils/tooltip-action-utils.js b/web/utils/tooltip-action-utils.js --- a/web/utils/tooltip-action-utils.js +++ b/web/utils/tooltip-action-utils.js @@ -5,7 +5,9 @@ import * as React from 'react'; import { useModalContext } from 'lib/components/modal-provider.react.js'; +import SWMansionIcon from 'lib/components/SWMansionIcon.react.js'; import type { ChatMessageInfoItem } from 'lib/selectors/chat-selectors.js'; +import { useCanEditMessage } from 'lib/shared/edit-messages-utils.js'; import { createMessageReply } from 'lib/shared/message-utils.js'; import { useCanCreateReactionFromMessage } from 'lib/shared/reaction-utils.js'; import { @@ -224,6 +226,32 @@ }, [canTogglePin, inputState, isPinned, pushModal, item, threadInfo]); } +function useMessageEditAction( + item: ChatMessageInfoItem, + threadInfo: ThreadInfo, +): ?MessageTooltipAction { + const { messageInfo } = item; + + const canEditMessage = useCanEditMessage(threadInfo, messageInfo); + + return React.useMemo(() => { + if (!canEditMessage) { + return null; + } + const buttonContent = ( + + ); + const onClickEdit = () => { + // TODO: Enter edit mode + }; + return { + actionButtonContent: buttonContent, + onClick: onClickEdit, + label: 'Edit', + }; + }, [canEditMessage]); +} + function useMessageTooltipActions( item: ChatMessageInfoItem, threadInfo: ThreadInfo, @@ -233,6 +261,7 @@ const copyAction = useMessageCopyAction(item); const reactAction = useMessageReactAction(item, threadInfo); const togglePinAction = useMessageTogglePinAction(item, threadInfo); + const editAction = useMessageEditAction(item, threadInfo); return React.useMemo( () => [ @@ -241,8 +270,16 @@ copyAction, reactAction, togglePinAction, + editAction, ].filter(Boolean), - [replyAction, sidebarAction, copyAction, reactAction, togglePinAction], + [ + replyAction, + sidebarAction, + copyAction, + reactAction, + togglePinAction, + editAction, + ], ); }