[FIX] web_editor: avoid double open of media modal when slow network

closes odoo/odoo#33327

Signed-off-by: Pierre Paridans <pparidans@users.noreply.github.com>
This commit is contained in:
Gorash
2019-05-22 11:49:52 +00:00
parent 4cbbab3d28
commit 4cbf5dc97b
@@ -44,6 +44,7 @@ var MediaPlugin = AbstractPlugin.extend({
},
mousePosition: {},
_modalOpen: false,
//--------------------------------------------------------------------------
// Public
@@ -53,6 +54,10 @@ var MediaPlugin = AbstractPlugin.extend({
* Open the image dialog and listen to its saved/closed events.
*/
showImageDialog: function () {
if (this._modalOpen) {
return;
}
this._modalOpen = true;
this.context.invoke('editor.saveRange');
var media = this.context.invoke('editor.restoreTarget');
@@ -72,6 +77,7 @@ var MediaPlugin = AbstractPlugin.extend({
});
mediaDialog.on('closed', this, function () {
this.context.invoke('editor.restoreRange');
this._modalOpen = false;
});
mediaDialog.open();
},