From fa91795b774c37b319b88e0aca638a3ae6c84def Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Tue, 15 Jul 2025 20:59:28 +0400 Subject: [PATCH] refac --- .../components/common/RichTextInput.svelte | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/lib/components/common/RichTextInput.svelte b/src/lib/components/common/RichTextInput.svelte index 93dc7913a4..5a946f188b 100644 --- a/src/lib/components/common/RichTextInput.svelte +++ b/src/lib/components/common/RichTextInput.svelte @@ -218,24 +218,24 @@ // Empty state, check if we have content to initialize // check if editor empty as well const isEmptyEditor = !editor || editor.getText().trim() === ''; - if (content && (data?.sessions ?? ['']).length === 1) { - if (isEmptyEditor) { + if (isEmptyEditor) { + if (content && (data?.sessions ?? ['']).length === 1) { const editorYdoc = prosemirrorJSONToYDoc(editor.schema, content); if (editorYdoc) { Y.applyUpdate(this.doc, Y.encodeStateAsUpdate(editorYdoc)); } + } + } else { + // If the editor already has content, we don't need to send an empty state + if (this.doc.getXmlFragment('prosemirror').length > 0) { + this.socket.emit('ydoc:document:update', { + document_id: this.documentId, + user_id: this.user?.id, + socket_id: this.socket.id, + update: Y.encodeStateAsUpdate(this.doc) + }); } else { - // If the editor already has content, we don't need to send an empty state - if (this.doc.getXmlFragment('prosemirror').length > 0) { - this.socket.emit('ydoc:document:update', { - document_id: this.documentId, - user_id: this.user?.id, - socket_id: this.socket.id, - update: Y.encodeStateAsUpdate(this.doc) - }); - } else { - console.warn('Yjs document is empty, not sending state.'); - } + console.warn('Yjs document is empty, not sending state.'); } } } else {