From d90841d7c4cff61eebd9e4429d1e390dd4416249 Mon Sep 17 00:00:00 2001 From: Nicolas Bayet Date: Mon, 6 Mar 2023 10:09:37 +0000 Subject: [PATCH] [FIX] web_editor: process historyStepsBuffer Before this commit, any history step received before the history is fully synchronised (`historySyncFinished`), would not be processed. As a fail safe, this commit adds a buffer that will be processed as soon as the history synchronization is finished (`historySyncFinished`). task-3217719 X-original-commit: acb58f921721b162954146f3c5364cb26823265f Part-of: odoo/odoo#114583 --- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 9451b1b1674..81a68883400 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -468,6 +468,7 @@ const Wysiwyg = Widget.extend({ // Wether or not the history has been sent or received at least once. let historySyncAtLeastOnce = false; let historySyncFinished = false; + let historyStepsBuffer = []; return new PeerToPeer({ peerConnectionConfig: { iceServers: this._iceServers }, @@ -556,6 +557,11 @@ const Wysiwyg = Widget.extend({ this.odooEditor.onExternalMultiselectionUpdate(remoteSelection); } } + // In case there are steps received in the meantime, process them. + if (historyStepsBuffer.length) { + this.odooEditor.onExternalHistorySteps(historyStepsBuffer); + historyStepsBuffer = []; + } historySyncFinished = true; } else { const remoteSelection = await this.ptp.requestClient(fromClientId, 'get_collaborative_selection', undefined, { transport: 'rtc' }); @@ -570,6 +576,8 @@ const Wysiwyg = Widget.extend({ // before the history has synced at least once. if (historySyncFinished) { this.odooEditor.onExternalHistorySteps([notificationPayload]); + } else { + historyStepsBuffer.push(notificationPayload); } break; case 'oe_history_set_selection': {