minor debouncing fixes for user card

This commit is contained in:
Sam 2014-11-06 10:30:38 +11:00
parent 20fa95801c
commit 7b484937d0
2 changed files with 14 additions and 0 deletions

View File

@ -7,6 +7,7 @@ export default ObjectController.extend({
username: null, username: null,
participant: null, participant: null,
avatar: null, avatar: null,
userLoading: null,
postStream: Em.computed.alias('controllers.topic.postStream'), postStream: Em.computed.alias('controllers.topic.postStream'),
enoughPostsForFiltering: Em.computed.gte('participant.post_count', 2), enoughPostsForFiltering: Em.computed.gte('participant.post_count', 2),
@ -60,6 +61,11 @@ export default ObjectController.extend({
return; return;
} }
if (username === currentUsername && this.get('userLoading') === username) {
// debounce
return;
}
this.set('participant', null); this.set('participant', null);
// Retrieve their participants info // Retrieve their participants info
@ -70,8 +76,12 @@ export default ObjectController.extend({
var self = this; var self = this;
self.set('user', null); self.set('user', null);
self.set('userLoading', username);
Discourse.User.findByUsername(username).then(function (user) { Discourse.User.findByUsername(username).then(function (user) {
self.setProperties({ user: user, avatar: user, visible: true}); self.setProperties({ user: user, avatar: user, visible: true});
}).finally(function(){
self.set('userLoading', null);
}); });
}, },

View File

@ -33,6 +33,10 @@ export default Discourse.View.extend(CleansUp, {
if ($target.closest('.trigger-user-card').length > 0) { return; } if ($target.closest('.trigger-user-card').length > 0) { return; }
if (self.$().has(e.target).length !== 0) { return; } if (self.$().has(e.target).length !== 0) { return; }
if ($target.data("userCard")|| $target.closest('a.mention')) {
return;
}
self.get('controller').close(); self.get('controller').close();
} }