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:
parent
95507864f0
commit
80940361fa
1 changed files with 11 additions and 6 deletions
|
@ -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;
|
||||||
|
@ -109,7 +114,7 @@ export default Component.extend(ShortcutsMixin, {
|
||||||
this.set('iconStyle', htmlSafe(`background-image: url(${icon})`));
|
this.set('iconStyle', htmlSafe(`background-image: url(${icon})`));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let iconUrl = 'https://static.ghost.org/v3.0.0/images/ghost-squircle.png';
|
let iconUrl = 'https://static.ghost.org/v3.0.0/images/ghost-squircle.png';
|
||||||
|
|
||||||
this.set('iconStyle', htmlSafe(`background-image: url(${iconUrl})`));
|
this.set('iconStyle', htmlSafe(`background-image: url(${iconUrl})`));
|
||||||
|
|
Loading…
Add table
Reference in a new issue