import { addFlagProperty } from 'discourse/controllers/header';

export default {
  name: 'add-akismet-count',
  before: 'map-routes',

  initialize(container) {
    const user = container.lookup('current-user:main');

    if (user && user.get('staff')) {
      addFlagProperty('currentUser.akismet_review_count');

      const messageBus = container.lookup('message-bus:main');
      messageBus.subscribe("/akismet_counts", function(result) {
        if (result) {
          user.set('akismet_review_count', result.akismet_review_count || 0);
        }
      });
    }
  }
};

import { addFlagProperty } from 'discourse/controllers/header';

export default {
  name: 'add-akismet-count',

  initialize(container) {
    const user = container.lookup('current-user:main');

    if (user && user.get('staff')) {
      addFlagProperty('currentUser.akismet_review_count');

      const messageBus = container.lookup('message-bus:main');
      messageBus.subscribe("/akismet_counts", function(result) {
        if (result) {
          user.set('akismet_review_count', result.akismet_review_count || 0);
        }
      });
    }
  }
};

Revert "Add the flagged property before routes are mapped."