Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3365965
D4917.id15858.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D4917.id15858.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D4917: [web] Introduce `useMessageTooltipReplyAction` hook
Attached
Detach File
Event Timeline
Log In to Comment