Page MenuHomePhabricator

D4917.id15858.diff
No OneTemporary

D4917.id15858.diff

diff --git a/web/chat/tooltip-utils.js b/web/chat/tooltip-utils.js
--- a/web/chat/tooltip-utils.js
+++ b/web/chat/tooltip-utils.js
@@ -4,10 +4,16 @@
import * as React from 'react';
import type { ChatMessageInfoItem } from 'lib/selectors/chat-selectors';
-import { useSidebarExistsOrCanBeCreated } from 'lib/shared/thread-utils';
+import { createMessageReply } from 'lib/shared/message-utils';
+import {
+ threadHasPermission,
+ useSidebarExistsOrCanBeCreated,
+} from 'lib/shared/thread-utils';
import type { ThreadInfo } from 'lib/types/thread-types';
+import { threadPermissions } from 'lib/types/thread-types';
import CommIcon from '../CommIcon.react';
+import { InputStateContext } from '../input/input-state';
import {
useOnClickPendingSidebar,
useOnClickThread,
@@ -347,10 +353,38 @@
threadCreatedFromMessage,
]);
}
+
+function useMessageTooltipReplyAction(
+ item: ChatMessageInfoItem,
+ threadInfo: ThreadInfo,
+): ?MessageTooltipAction {
+ const { messageInfo } = item;
+ const inputState = React.useContext(InputStateContext);
+ invariant(inputState, 'inputState is required');
+ const { addReply } = inputState;
+ return React.useMemo(() => {
+ if (!threadHasPermission(threadInfo, threadPermissions.VOICED)) {
+ return null;
+ }
+ const buttonContent = <CommIcon icon="reply-filled" size={18} />;
+ const onClick = () => {
+ if (!messageInfo.text) {
+ return;
+ }
+ addReply(createMessageReply(messageInfo.text));
+ };
+ return {
+ actionButtonContent: buttonContent,
+ onClick,
+ label: 'Reply',
+ };
+ }, [addReply, messageInfo, threadInfo]);
+}
export {
findTooltipPosition,
calculateTooltipSize,
getMessageActionTooltipStyle,
useMessageTooltipSidebarAction,
+ useMessageTooltipReplyAction,
sizeOfTooltipArrow,
};

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 8:44 AM (21 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2584057
Default Alt Text
D4917.id15858.diff (1 KB)

Event Timeline