From de627a3dfce3baf7cc36ed7c82773d7e3566739a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Sun, 18 Jun 2023 21:54:03 +0200 Subject: [PATCH] fix: Pass origin along the initial state update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- src/components/Editor.vue | 2 +- src/helpers/yjs.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/Editor.vue b/src/components/Editor.vue index 7464252e760..c9bdee3b49c 100644 --- a/src/components/Editor.vue +++ b/src/components/Editor.vue @@ -480,7 +480,7 @@ export default { onLoaded({ documentSource, documentState }) { if (documentState) { - applyDocumentState(this.$ydoc, documentState) + applyDocumentState(this.$ydoc, documentState, this.$providers[0]) } this.hasConnectionIssue = false diff --git a/src/helpers/yjs.js b/src/helpers/yjs.js index 4243e5750da..bc83c1e30a5 100644 --- a/src/helpers/yjs.js +++ b/src/helpers/yjs.js @@ -36,8 +36,9 @@ export function getDocumentState(ydoc) { * * @param {Doc} ydoc - apply state to this doc * @param {string} documentState - base64 encoded doc state + * @param {object} origin - initiator object e.g. WebsocketProvider */ -export function applyDocumentState(ydoc, documentState) { +export function applyDocumentState(ydoc, documentState, origin) { const update = decodeArrayBuffer(documentState) - applyUpdate(ydoc, update) + applyUpdate(ydoc, update, origin) }