This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/controllers/user-notifications.js.es6
Robin Ward bf91532260 Fixes some Ember Deprecations for 1.13:
- Remove ArrayController
- Remove {{view}} from templates
- Replace many cases of needs: [‘controller’] with inject
- Enable Ember Legacy Views
2016-10-21 11:06:07 -04:00

34 lines
821 B
JavaScript

import { ajax } from 'discourse/lib/ajax';
import { default as computed, observes } from 'ember-addons/ember-computed-decorators';
export default Ember.Controller.extend({
application: Ember.inject.controller(),
@observes('model.canLoadMore')
_showFooter() {
this.set("application.showFooter", !this.get("model.canLoadMore"));
},
@computed('model.content.length')
hasNotifications(length) {
return length > 0;
},
@computed('model.content.@each.read')
allNotificationsRead() {
return !this.get('model.content').some(notification => !notification.get('read'));
},
actions: {
resetNew() {
ajax('/notifications/mark-read', { method: 'PUT' }).then(() => {
this.setEach('read', true);
});
},
loadMore() {
this.get('model').loadMore();
}
}
});