- new "show-footer" mixins - converted most of the routes to ES6 - FIX: handling of "indexStream" in user pages There will now be a footer on all the following pages - /exception - /about - /latest - /new - /unread - /starred - /top - /categories - /c/:category - /c/:category/l/latest - /c/:category/l/new - /c/:category/l/unread - /c/:category/l/top - /t/:topic/:id - /groups/:name/members - /user/activity - /user/activity/topics - /user/activity/posts - /user/activity/replies - /user/activity/likes-given - /user/activity/likes-received - /user/activity/bookmarks - /user/activity/starred - /user/badges - /user/notifications - /user/flagged-posts - /user/deleted-posts - /user/private-messages - /user/private-messages/mine - /user/private-messages/unread - /user/invited - /user/:username/preferences - /faq (static pages) - /badges - /badges/:id/:badge
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
|
|
export default Ember.ArrayController.extend({
|
|
needs: ['user-notifications', 'application'],
|
|
loading: false,
|
|
|
|
_showFooter: function() {
|
|
this.set("controllers.application.showFooter", !this.get("canLoadMore"));
|
|
}.observes("canLoadMore"),
|
|
|
|
showDismissButton: function() {
|
|
return this.get('user').total_unread_notifications > 0;
|
|
}.property('user'),
|
|
|
|
actions: {
|
|
resetNew: function() {
|
|
var self = this;
|
|
Discourse.NotificationContainer.resetNew().then(function() {
|
|
self.get('controllers.user-notifications').setEach('read', true);
|
|
});
|
|
},
|
|
|
|
loadMore: function() {
|
|
if (this.get('canLoadMore') && !this.get('loading')) {
|
|
this.set('loading', true);
|
|
var self = this;
|
|
Discourse.NotificationContainer.loadHistory(
|
|
self.get('model.lastObject.created_at'),
|
|
self.get('user.username')).then(function(result) {
|
|
self.set('loading', false);
|
|
var notifications = result.get('content');
|
|
self.pushObjects(notifications);
|
|
// Stop trying if it's the end
|
|
if (notifications && (notifications.length === 0 || notifications.length < 60)) {
|
|
self.set('canLoadMore', false);
|
|
}
|
|
}).catch(function(error) {
|
|
self.set('loading', false);
|
|
Em.Logger.error(error);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
});
|