|
1 | | -import type { FC } from "react"; |
2 | | -import { useRef, useState } from "react"; |
| 1 | +import { useCallback, useRef, useState } from "react"; |
3 | 2 | import { observer } from "mobx-react"; |
4 | 3 | // plane imports |
| 4 | +import { EmojiReactionButton, EmojiReactionPicker } from "@plane/propel/emoji-reaction"; |
5 | 5 | import type { EditorRefApi } from "@plane/editor"; |
6 | 6 | import type { TIssueComment, TCommentsOperations } from "@plane/types"; |
7 | 7 | // plane web imports |
@@ -35,25 +35,48 @@ export const CommentCard = observer(function CommentCard(props: TCommentCard) { |
35 | 35 | } = props; |
36 | 36 | // states |
37 | 37 | const [isEditing, setIsEditing] = useState(false); |
| 38 | + const [isPickerOpen, setIsPickerOpen] = useState(false); |
38 | 39 | // refs |
39 | 40 | const readOnlyEditorRef = useRef<EditorRefApi>(null); |
40 | 41 | // derived values |
41 | 42 | const workspaceId = comment?.workspace; |
42 | 43 |
|
| 44 | + const userReactions = comment?.id ? activityOperations.userReactions(comment.id) : undefined; |
| 45 | + |
| 46 | + const handleEmojiSelect = useCallback( |
| 47 | + (emoji: string) => { |
| 48 | + if (!userReactions || !comment?.id) return; |
| 49 | + // emoji is already in decimal string format from EmojiReactionPicker |
| 50 | + void activityOperations.react(comment.id, emoji, userReactions); |
| 51 | + }, |
| 52 | + [activityOperations, comment?.id, userReactions] |
| 53 | + ); |
| 54 | + |
43 | 55 | if (!comment || !workspaceId) return null; |
44 | 56 |
|
45 | 57 | return ( |
46 | 58 | <CommentBlock |
47 | 59 | comment={comment} |
48 | 60 | quickActions={ |
49 | 61 | !disabled && ( |
50 | | - <CommentQuickActions |
51 | | - activityOperations={activityOperations} |
52 | | - comment={comment} |
53 | | - setEditMode={() => setIsEditing(true)} |
54 | | - showAccessSpecifier={showAccessSpecifier} |
55 | | - showCopyLinkOption={showCopyLinkOption} |
56 | | - /> |
| 62 | + <div className="flex items-center gap-1"> |
| 63 | + <EmojiReactionPicker |
| 64 | + isOpen={isPickerOpen} |
| 65 | + handleToggle={setIsPickerOpen} |
| 66 | + onChange={handleEmojiSelect} |
| 67 | + disabled={disabled} |
| 68 | + label={<EmojiReactionButton onAddReaction={() => setIsPickerOpen(true)} />} |
| 69 | + placement="bottom-start" |
| 70 | + /> |
| 71 | + |
| 72 | + <CommentQuickActions |
| 73 | + activityOperations={activityOperations} |
| 74 | + comment={comment} |
| 75 | + setEditMode={() => setIsEditing(true)} |
| 76 | + showAccessSpecifier={showAccessSpecifier} |
| 77 | + showCopyLinkOption={showCopyLinkOption} |
| 78 | + /> |
| 79 | + </div> |
57 | 80 | ) |
58 | 81 | } |
59 | 82 | ends={ends} |
|
0 commit comments