FIX: double XHR request when loading more badges

This commit is contained in:
Sam 2016-03-29 16:56:29 +11:00
parent 418bc4a844
commit 7ab153dac3
1 changed files with 7 additions and 0 deletions

View File

@ -21,6 +21,11 @@ export default Ember.Controller.extend({
actions: { actions: {
loadMore() { loadMore() {
if (this.get('loadingMore')) {
return;
}
this.set('loadingMore', true);
const userBadges = this.get('userBadges'); const userBadges = this.get('userBadges');
UserBadge.findByBadgeId(this.get('model.id'), { UserBadge.findByBadgeId(this.get('model.id'), {
@ -31,6 +36,8 @@ export default Ember.Controller.extend({
if (userBadges.length === 0){ if (userBadges.length === 0){
this.set('noMoreBadges', true); this.set('noMoreBadges', true);
} }
}).finally(()=>{
this.set('loadingMore', false);
}); });
} }
}, },