0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Fixed members count load on main nav

refs 1f46af4ed9

- Fixes test and updates member count load on main nav
This commit is contained in:
Rish 2021-03-04 23:04:59 +05:30
parent 95507864f0
commit 80940361fa

View file

@ -6,6 +6,7 @@ import {computed} from '@ember/object';
import {getOwner} from '@ember/application'; import {getOwner} from '@ember/application';
import {htmlSafe} from '@ember/string'; import {htmlSafe} from '@ember/string';
import {inject as service} from '@ember/service'; import {inject as service} from '@ember/service';
import {task} from 'ember-concurrency';
export default Component.extend(ShortcutsMixin, { export default Component.extend(ShortcutsMixin, {
billing: service(), billing: service(),
@ -55,7 +56,7 @@ export default Component.extend(ShortcutsMixin, {
// so that we can refresh when a new icon is uploaded // so that we can refresh when a new icon is uploaded
didReceiveAttrs() { didReceiveAttrs() {
this._setIconStyle(); this._setIconStyle();
// this._loadMemberCount(); this._loadMemberCountsTask.perform();
}, },
didInsertElement() { didInsertElement() {
@ -85,16 +86,20 @@ export default Component.extend(ShortcutsMixin, {
} }
}, },
_loadMemberCount() { _loadMemberCountsTask: task(function* () {
this.membersStats.fetchCounts().then((stats) => { try {
this.set('memberCountLoading', true);
const stats = yield this.membersStats.fetchCounts();
this.set('memberCountLoading', false); this.set('memberCountLoading', false);
if (stats) { if (stats) {
const statsDateObj = this.membersStats.fillCountDates(stats.data) || {}; const statsDateObj = this.membersStats.fillCountDates(stats.data) || {};
const dateValues = Object.values(statsDateObj); const dateValues = Object.values(statsDateObj);
this.set('memberCount', dateValues.length ? dateValues[dateValues.length - 1].total : 0); this.set('memberCount', dateValues.length ? dateValues[dateValues.length - 1].total : 0);
} }
}); } catch (e) {
}, return false;
}
}),
_setIconStyle() { _setIconStyle() {
let icon = this.icon; let icon = this.icon;