mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 04:42:55 +08:00
FIX: Flags weren't showing on the header
This commit is contained in:
parent
e1f9f6d02a
commit
3830bb7d78
|
@ -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;
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
import { applyFlaggedProperties } from 'discourse/controllers/header';
|
||||
|
||||
export default {
|
||||
name: 'apply-flagged-properties',
|
||||
after: 'map-routes',
|
||||
initialize: applyFlaggedProperties
|
||||
};
|
|
@ -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());
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user