From ac5bc7b0f0637331b2da32793178819a81a33f5f 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 71376f664e0..8be3cd21622 100644 --- a/src/components/Editor.vue +++ b/src/components/Editor.vue @@ -464,7 +464,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) }