From 5da324103a5659c9144f33e9d748f47191045141 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Wed, 12 Jul 2017 16:04:10 -0700 Subject: [PATCH] Throttle calls to getProfile when opening conversation We don't want to throttle other calls to getProfile, so we localize this to the fetch we do when we first open a conversation. FREEBIE --- js/views/conversation_view.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index 0482dc355..f74c661e5 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -108,7 +108,11 @@ this.lazyUpdateVerified = _.debounce( this.model.updateVerified.bind(this.model), - 1000 + 1000 // one second + ); + this.throttledGetProfiles = _.throttle( + this.model.getProfiles.bind(this.model), + 1000 * 60 * 5 // five minutes ); this.render(); @@ -320,7 +324,7 @@ onOpened: function() { // TODO: we may want to show a loading dialog until this status fetch // and potentially the below message fetch are complete. - this.statusFetch = this.model.getProfiles().then(function() { + this.statusFetch = this.throttledGetProfiles().then(function() { this.model.updateVerified().then(function() { this.onVerifiedChange(); this.statusFetch = null;