From 952708d8b13a3af01d63c10d9ab1b02de844411f Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Thu, 6 Sep 2018 16:03:48 +0200 Subject: [PATCH] * Mail: avoid to send so many requests when user tries to scroll on mail list via key up/down --- mail/js/app.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/mail/js/app.js b/mail/js/app.js index ef3b1eea32..6ba7a4f8b0 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -70,6 +70,12 @@ app.classes.mail = AppJS.extend( */ W_INTERVALS:[], + /** + * + * @array of setted timeouts + */ + W_TIMEOUTS: [], + /** * Initialize javascript for this application * @@ -1062,12 +1068,19 @@ app.classes.mail = AppJS.extend( this.mail_selectedMails.push(_id); } var self = this; - // Request email body from server - IframeHandle.set_src(egw.link('/index.php',{menuaction:'mail.mail_ui.loadEmailBody',_messageID:_id})); - jQuery(IframeHandle.getDOMNode()).on('load', function(e){ - self.resolveExternalImages (this.contentWindow.document); - }); + // Try to avoid sending so many request when user tries to scroll on list + // via key up/down quite fast. + for (var t in this.W_TIMEOUTS) {window.clearTimeout(this.W_TIMEOUTS[t]);} + this.W_TIMEOUTS.push(window.setTimeout(function(){ + + console.log(_id); + // Request email body from server + IframeHandle.set_src(egw.link('/index.php',{menuaction:'mail.mail_ui.loadEmailBody',_messageID:_id})); + jQuery(IframeHandle.getDOMNode()).on('load', function(e){ + self.resolveExternalImages (this.contentWindow.document); + }); + }, 300)); } if (dataElem.data['smime']) this.smimeAttachmentsCheckerInterval(); var messages = {};