From 0d4d0409ec24534b0485d0eb68bf9be0b2ececba Mon Sep 17 00:00:00 2001 From: Nicolas Bayet Date: Tue, 5 Sep 2023 15:52:37 +0200 Subject: [PATCH] [FIX] web_editor: ensure the bus is available In the frontend of project, the bus service is not available. Since #129785, the test `portal_project_sharing_tour` crash because `this.busService` is `undefined` when we try to access it in `Wysiwyg.setupCollaboration`. task-3434068 closes odoo/odoo#133477 Related: odoo/enterprise#46479 Signed-off-by: David Monjoie (dmo) --- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 3e6370d2d9e..912ecb82799 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -325,10 +325,7 @@ export class Wysiwyg extends Component { const powerboxOptions = this._getPowerboxOptions(); let editorCollaborationOptions; - if ( - options.collaborationChannel && - this._hasICEServers() - ) { + if (this._isCollaborationEnabled(options)) { editorCollaborationOptions = this.setupCollaboration(options.collaborationChannel); if (this.options.collaborativeTrigger === 'start') { this._joinPeerToPeer(); @@ -2878,7 +2875,7 @@ export class Wysiwyg extends Component { this._stopPeerToPeer(); this._rulesCache = undefined; // Reset the cache of rules. // If there is no collaborationResId, the record has been deleted. - if (!collaborationChannel || !collaborationChannel.collaborationResId) { + if (!this._isCollaborationEnabled(this.options)) { this.setValue(value); this.odooEditor.historyReset(); return; @@ -2931,6 +2928,9 @@ export class Wysiwyg extends Component { // Hack: check if mail module is installed. return session.notification_type; } + _isCollaborationEnabled(options) { + return options.collaborationChannel && options.collaborationChannel.collaborationResId && this._hasICEServers() && this.busService; + } /** * Saves a base64 encoded image as an attachment.