From 32e294e7dae298edb4d421d78a309f583b2c4fed Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Mon, 16 Dec 2019 15:24:19 +0000 Subject: [PATCH] [REF] web_editor: regroup snippets menu mutexes Snippet enabling operations and snippet edition operations were mutexed individually. In fact it simplifies the code and it is probably better to chain all snippet operations, through an unique mutex. Part of https://github.com/odoo/odoo/pull/41789 --- addons/web_editor/static/src/js/editor/snippets.editor.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js index 3e2790cdeb0..34701a34034 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -786,10 +786,9 @@ var SnippetsMenu = Widget.extend({ this.options.snippets = 'web_editor.snippets'; } this.snippetEditors = []; - this._activateSnippetMutex = new concurrency.Mutex(); this._enabledEditorHierarchy = []; - this._snippetEditionMutex = new concurrency.Mutex(); + this._mutex = new concurrency.Mutex(); this.setSelectorEditableArea(options.$el, options.selectorEditableArea); @@ -1195,7 +1194,7 @@ var SnippetsMenu = Widget.extend({ if (this._blockPreviewOverlays && previewMode) { return Promise.resolve(); } - return this._activateSnippetMutex.exec(() => { + return this._mutex.exec(() => { return new Promise(resolve => { // Take the first parent of the provided DOM (or itself) which // should have an associated snippet editor and create + enable it. @@ -1952,7 +1951,7 @@ var SnippetsMenu = Widget.extend({ * @param {function} ev.data.exec */ _onSnippetEditionRequest: function (ev) { - this._snippetEditionMutex.exec(ev.data.exec); + this._mutex.exec(ev.data.exec); }, /** * @private