From 87563f875cc3485e56f06b208e33e1e2af8eecdf Mon Sep 17 00:00:00 2001 From: David Monjoie Date: Fri, 20 May 2022 08:32:49 +0000 Subject: [PATCH] [REF] web_editor: remove unused variable The `hasSearch` variable on `this` was not used anywhere and, if it was, its semantic was arguable because it was set true as soon as the search was fired rather than when the search had returned. I'm taking this opportunity to use async/await as it's *way* better here. closes odoo/odoo#92014 Signed-off-by: Romain Derie (rde) --- .../static/src/js/wysiwyg/widgets/media.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/widgets/media.js b/addons/web_editor/static/src/js/wysiwyg/widgets/media.js index 47ce70766fb..76a7ecbb15a 100644 --- a/addons/web_editor/static/src/js/wysiwyg/widgets/media.js +++ b/addons/web_editor/static/src/js/wysiwyg/widgets/media.js @@ -118,17 +118,14 @@ var SearchableMediaWidget = MediaWidget.extend({ /** * @private */ - _onSearchInput: function (ev) { + _onSearchInput: async function (ev) { this.attachments = []; // Disable user interactions with attachments while updating results. this.$('.o_we_existing_attachments').css('pointer-events', 'none'); - this.search($(ev.currentTarget).val() || "") - .then(() => this._renderThumbnails()) - .then(() => { - // Re-enable user interactions after updating results. - this.$(".o_we_existing_attachments").css("pointer-events", ""); - }); - this.hasSearched = true; + await this.search($(ev.currentTarget).val() || ''); + await this._renderThumbnails(); + // Re-enable user interactions with attachments after updating results. + this.$('.o_we_existing_attachments').css('pointer-events', ''); }, });