Skip to content

Commit 38af393

Browse files
committed
fix: message composer bugs!!!!
1 parent dc18cc2 commit 38af393

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

packages/webapp/components/chat/components/MessageComposer/MessageComposer.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ const MessageComposer = ({
127127
const validateSubmission = useCallback(() => {
128128
if (!editor || !user) return { isValid: false, error: 'Editor or user not available' }
129129

130-
console.log('html-text', { html, text })
131-
132130
const isContentEmpty =
133131
!html || !text || html.replace(/<[^>]*>/g, '').trim() === '' || text.trim() === ''
134132
if (isContentEmpty) return { isValid: false, error: 'Content is empty' }
@@ -141,10 +139,6 @@ const MessageComposer = ({
141139
// Content preparation
142140
const prepareContent = useCallback(() => {
143141
const { sanitizedHtml, sanitizedText } = sanitizeMessageContent(html, text)
144-
console.log({
145-
sanitizedHtml,
146-
sanitizedText
147-
})
148142

149143
if (!sanitizedHtml || !sanitizedText) {
150144
throw new Error('Invalid content detected')
@@ -207,7 +201,8 @@ const MessageComposer = ({
207201
const fakemessage = createFakeMessage(content, html, user, channelId)
208202
messageInsert(fakemessage)
209203

210-
await sendMessage(content, channelId, user.id, html, messageId)
204+
const { error } = await sendMessage(content, channelId, user.id, html, messageId)
205+
if (error) console.error('[handleRegularMessage]', error)
211206
return true
212207
},
213208
[user, channelId, messageInsert, sendMessage]
@@ -319,6 +314,7 @@ const MessageComposer = ({
319314
user_details: user,
320315
channel_id: channelId,
321316
user_id: user.id,
317+
user_details: user,
322318
created_at: currentDate,
323319
updated_at: currentDate
324320
}

packages/webapp/components/chat/components/MessageComposer/components/Input/Input.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export const Input = () => {
66
const { editorRef, editor, messageDraftMemory } = useMessageComposer()
77

88
useEffect(() => {
9-
console.log('we are setting the content ======>>>>', messageDraftMemory)
109
if (messageDraftMemory) {
1110
editor?.commands.setContent(messageDraftMemory.html)
1211
}

packages/webapp/hooks/useCopyToDoc.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,18 @@ export const useCopyToDoc = () => {
9393
headingPos !== null && headingNode
9494
? headingPos +
9595
Number(headingNode.content.size) -
96-
Number(secondHeadingNode.content.size) -
96+
Number(secondHeadingNode?.content.size) -
9797
2 // End of current heading's content
9898
: doc.content.size - 2 || 0 // End of document if heading not found
9999

100100
if (headingLevel === 1) {
101101
insertPosition = secondHeadingPos !== null ? secondHeadingPos : insertPosition
102102
}
103103

104+
if (!insertPosition) {
105+
insertPosition = headingPos + headingNode?.firstChild?.content.size + 4
106+
}
107+
104108
// Insert content at calculated position
105109
const insertAndUpdate = () => {
106110
editor

0 commit comments

Comments
 (0)