Skip to content

Commit bd9e659

Browse files
committed
feat: enhance load persisted draft to track emoji-only messages
1 parent b50c044 commit bd9e659

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

packages/webapp/components/chatroom/components/MessageComposer/MessageComposer.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
ComposerState
1313
} from '@db/messageComposerDB'
1414
import { SignInDialog } from '@components/ui/dialogs'
15+
import { isOnlyEmoji } from '@utils/emojis'
1516

1617
import { EditorContent } from '@tiptap/react'
1718
import {
@@ -94,7 +95,7 @@ const MessageComposer = ({
9495
// Simple ref for the submit callback
9596
const submitRef = useRef<(() => void) | null>(null)
9697

97-
const { editor, text, html, isEmojiOnly } = useTiptapEditor({
98+
const { editor, text, html, isEmojiOnly, setIsEmojiOnly } = useTiptapEditor({
9899
loading,
99100
onSubmit: () => submitRef.current?.(),
100101
workspaceId,
@@ -140,6 +141,8 @@ const MessageComposer = ({
140141
}
141142
// Restore toolbar state
142143
if (draft?.isToolbarOpen !== undefined) setIsToolbarOpen(draft.isToolbarOpen)
144+
145+
if (isOnlyEmoji(draft?.text ?? '')) setIsEmojiOnly(true)
143146
})
144147
}, [editor, workspaceId, channelId, editMessageMemory, replyMessageMemory, commentMessageMemory])
145148

packages/webapp/components/chatroom/components/MessageComposer/hooks/useTiptapEditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,5 +225,5 @@ export const useTiptapEditor = ({
225225
editor.setEditable(!loading)
226226
}, [loading, editor])
227227

228-
return { editor, html, text, isEmojiOnly }
228+
return { editor, html, text, isEmojiOnly, setIsEmojiOnly }
229229
}

0 commit comments

Comments
 (0)