From 5dc180a3ea50083c88399a58ee07cd130fa8289d Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Mon, 30 Jul 2018 10:35:24 +0200 Subject: [PATCH] [FIX] im_livechat: double click on :) => 1 message Prevent sending multiple messages when multiple clicks on one feedback icon. opw-1863312 closes #26047 --- addons/im_livechat/static/src/js/im_livechat.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/im_livechat/static/src/js/im_livechat.js b/addons/im_livechat/static/src/js/im_livechat.js index 10cc5610214..e9cc424f2a2 100644 --- a/addons/im_livechat/static/src/js/im_livechat.js +++ b/addons/im_livechat/static/src/js/im_livechat.js @@ -3,6 +3,7 @@ odoo.define('im_livechat.im_livechat', function (require) { var local_storage = require('web.local_storage'); var bus = require('bus.bus').bus; +var concurrency = require('web.concurrency'); var config = require('web.config'); var core = require('web.core'); var session = require('web.session'); @@ -304,6 +305,7 @@ var Feedback = Widget.extend({ this.channel_uuid = channel_uuid; this.server_origin = session.origin; this.rating = undefined; + this.dp = new concurrency.DropPrevious(); }, on_click_smiley: function (ev) { @@ -339,7 +341,7 @@ var Feedback = Widget.extend({ rate: this.rating, reason : options.reason }; - return session.rpc('/im_livechat/feedback', args).then(function () { + this.dp.add(session.rpc('/im_livechat/feedback', args)).then(function () { if (options.close) { var content = _.str.sprintf(_t("Rating: :rating_%d"), self.rating); if (options.reason) {