summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/js/composer.js
diff options
context:
space:
mode:
authordbh <dbh@odoo.com>2016-10-27 14:29:27 +0530
committerYannick Tivisse <yti@odoo.com>2017-01-03 10:37:29 +0100
commit22b91872ec329b7a8b7f9207ba9b26edcfffa6f5 (patch)
tree4a3c0af011e49345aa9cbef2d17bfa6e3f5942db /addons/mail/static/src/js/composer.js
parent5d0b9285449257e6878091ddead022cefda73bce (diff)
[IMP] mail: add delay of 500ms to display the canned responses
Diffstat (limited to 'addons/mail/static/src/js/composer.js')
-rw-r--r--addons/mail/static/src/js/composer.js19
1 files changed, 13 insertions, 6 deletions
diff --git a/addons/mail/static/src/js/composer.js b/addons/mail/static/src/js/composer.js
index a3b86e54c8c..657f9feea14 100644
--- a/addons/mail/static/src/js/composer.js
+++ b/addons/mail/static/src/js/composer.js
@@ -490,6 +490,7 @@ var BasicComposer = Widget.extend({
return;
}
+ clearTimeout(this.canned_timeout);
var self = this;
this.preprocess_message().then(function (message) {
self.trigger('post_message', message);
@@ -713,12 +714,18 @@ var BasicComposer = Widget.extend({
});
},
mention_get_canned_responses: function (search) {
- var canned_responses = chat_manager.get_canned_responses();
- var matches = fuzzy.filter(utils.unaccent(search), _.pluck(canned_responses, 'source'));
- var indexes = _.pluck(matches.slice(0, this.options.mention_fetch_limit), 'index');
- return _.map(indexes, function (i) {
- return canned_responses[i];
- });
+ var self = this;
+ var def = $.Deferred();
+ clearTimeout(this.canned_timeout);
+ this.canned_timeout = setTimeout(function() {
+ var canned_responses = chat_manager.get_canned_responses();
+ var matches = fuzzy.filter(utils.unaccent(search), _.pluck(canned_responses, 'source'));
+ var indexes = _.pluck(matches.slice(0, self.options.mention_fetch_limit), 'index');
+ def.resolve(_.map(indexes, function (i) {
+ return canned_responses[i];
+ }));
+ }, 500);
+ return def;
},
mention_get_commands: function (search) {
var search_regexp = new RegExp(_.str.escapeRegExp(utils.unaccent(search)), 'i');