From 7b484937d09c4bdbe2a7ca76595373ff4e5f5a60 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 6 Nov 2014 10:30:38 +1100 Subject: [PATCH] minor debouncing fixes for user card --- .../javascripts/discourse/controllers/user-card.js.es6 | 10 ++++++++++ .../javascripts/discourse/views/user-card.js.es6 | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/app/assets/javascripts/discourse/controllers/user-card.js.es6 b/app/assets/javascripts/discourse/controllers/user-card.js.es6 index b29f1abee7c..8294b4e241b 100644 --- a/app/assets/javascripts/discourse/controllers/user-card.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user-card.js.es6 @@ -7,6 +7,7 @@ export default ObjectController.extend({ username: null, participant: null, avatar: null, + userLoading: null, postStream: Em.computed.alias('controllers.topic.postStream'), enoughPostsForFiltering: Em.computed.gte('participant.post_count', 2), @@ -60,6 +61,11 @@ export default ObjectController.extend({ return; } + if (username === currentUsername && this.get('userLoading') === username) { + // debounce + return; + } + this.set('participant', null); // Retrieve their participants info @@ -70,8 +76,12 @@ export default ObjectController.extend({ var self = this; self.set('user', null); + + self.set('userLoading', username); Discourse.User.findByUsername(username).then(function (user) { self.setProperties({ user: user, avatar: user, visible: true}); + }).finally(function(){ + self.set('userLoading', null); }); }, diff --git a/app/assets/javascripts/discourse/views/user-card.js.es6 b/app/assets/javascripts/discourse/views/user-card.js.es6 index 9c438fc0bac..474905496b2 100644 --- a/app/assets/javascripts/discourse/views/user-card.js.es6 +++ b/app/assets/javascripts/discourse/views/user-card.js.es6 @@ -33,6 +33,10 @@ export default Discourse.View.extend(CleansUp, { if ($target.closest('.trigger-user-card').length > 0) { return; } if (self.$().has(e.target).length !== 0) { return; } + if ($target.data("userCard")|| $target.closest('a.mention')) { + return; + } + self.get('controller').close(); }