FIX: Badge loading more was stuck

This commit is contained in:
Robin Ward 2016-03-25 11:23:31 -04:00
parent 9e9c81c30b
commit d129c61a4a
3 changed files with 12 additions and 16 deletions

View File

@ -1,4 +1,5 @@
import UserBadge from 'discourse/models/user-badge';
import computed from 'ember-addons/ember-computed-decorators';
export default Ember.Controller.extend({
queryParams: ['username'],
@ -22,30 +23,25 @@ export default Ember.Controller.extend({
actions: {
loadMore() {
const self = this;
const userBadges = this.get('userBadges');
UserBadge.findByBadgeId(this.get('model.id'), {
offset: userBadges.length,
username: this.get('username'),
}).then(function(result) {
}).then(result => {
userBadges.pushObjects(result);
if(userBadges.length === 0){
self.set('noMoreBadges', true);
if (userBadges.length === 0){
this.set('noMoreBadges', true);
}
});
}
},
canLoadMore: function() {
if (this.get('noMoreBadges')) { return false; }
if (this.get('userBadges')) {
return this.get('grantCount') > this.get('userBadges.length');
} else {
return false;
}
}.property('noMoreBadges', 'model.grant_count', 'userBadges.length'),
@computed('noMoreBadges', 'model.grant_count', 'userBadges.length')
canLoadMore(noMoreBadges, grantCount, userBadgeLength) {
if (noMoreBadges) { return false; }
return grantCount > (userBadgeLength || 0);
},
_showFooter: function() {
this.set("controllers.application.showFooter", !this.get("canLoadMore"));

View File

@ -7,7 +7,7 @@ export default Ember.Mixin.create(Ember.ViewTargetActionSupport, Scrolling, {
scrolled() {
const eyeline = this.get('eyeline');
if (eyeline) { eyeline.update(); }
return eyeline && eyeline.update();
},
loadMoreUnlessFull() {

View File

@ -1,7 +1,7 @@
import LoadMore from "discourse/mixins/load-more";
export default Ember.View.extend(LoadMore, {
eyelineSelector: '.badge-user',
eyelineSelector: '.badge-info',
tickOrX: function(field){
var icon = this.get('controller.model.' + field) ? "fa-check" : "fa-times";
return "<i class='fa " + icon + "'></i>";