mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-18 07:15:20 +00:00
refac
This commit is contained in:
parent
0aabbdd23a
commit
fa91795b77
1 changed files with 13 additions and 13 deletions
|
|
@ -218,24 +218,24 @@
|
||||||
// Empty state, check if we have content to initialize
|
// Empty state, check if we have content to initialize
|
||||||
// check if editor empty as well
|
// check if editor empty as well
|
||||||
const isEmptyEditor = !editor || editor.getText().trim() === '';
|
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);
|
const editorYdoc = prosemirrorJSONToYDoc(editor.schema, content);
|
||||||
if (editorYdoc) {
|
if (editorYdoc) {
|
||||||
Y.applyUpdate(this.doc, Y.encodeStateAsUpdate(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 {
|
} else {
|
||||||
// If the editor already has content, we don't need to send an empty state
|
console.warn('Yjs document is empty, not sending 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.');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue