FIX: Flags weren't showing on the header

This commit is contained in:
Robin Ward 2015-05-08 12:13:40 -04:00
parent e1f9f6d02a
commit 3830bb7d78
3 changed files with 19 additions and 19 deletions

View File

@ -80,27 +80,18 @@ function addFlagProperty(prop) {
_flagProperties.pushObject(prop);
}
let _appliedFlagProps = false;
HeaderController.reopenClass({
create() {
// We only want to change the class the first time it's created
if (!_appliedFlagProps && _flagProperties.length) {
_appliedFlagProps = true;
const args = _flagProperties.slice();
args.push(function() {
let sum = 0;
_flagProperties.forEach((fp) => sum += (this.get(fp) || 0));
return sum;
});
HeaderController.reopen({ flaggedPostsCount: Ember.computed.apply(this, args) });
}
return this._super.apply(this, Array.prototype.slice.call(arguments));
}
});
function applyFlaggedProperties() {
const args = _flagProperties.slice();
args.push(function() {
let sum = 0;
_flagProperties.forEach((fp) => sum += (this.get(fp) || 0));
return sum;
});
HeaderController.reopen({ flaggedPostsCount: Ember.computed.apply(this, args) });
}
addFlagProperty('currentUser.site_flagged_posts_count');
addFlagProperty('currentUser.post_queue_new_count');
export { addFlagProperty };
export { addFlagProperty, applyFlaggedProperties };
export default HeaderController;

View File

@ -0,0 +1,7 @@
import { applyFlaggedProperties } from 'discourse/controllers/header';
export default {
name: 'apply-flagged-properties',
after: 'map-routes',
initialize: applyFlaggedProperties
};

View File

@ -2,6 +2,8 @@ import { mapRoutes } from 'discourse/router';
export default {
name: "map-routes",
after: 'inject-objects',
initialize(container, app) {
app.register('router:main', mapRoutes());