mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-09-11 12:55:37 +03:00
Replaced menu members count stats API with members count cache (#19476)
no issue The members stats API is a lot more slower than the normal members count cache, and we use the members count cache in a lot more places. So we can cache it more.
This commit is contained in:
parent
1f2857e0e4
commit
d468563feb
@ -100,15 +100,19 @@
|
||||
<li class="relative">
|
||||
{{#if (eq this.router.currentRouteName "members.index")}}
|
||||
<LinkTo @route="members" @current-when="members member member.new" @query={{reset-query-params "members.index"}} data-test-nav="members">{{svg-jar "members"}}Members
|
||||
{{#unless this.memberCountLoading}}
|
||||
<span class="gh-nav-member-count">{{format-number this.membersStats.memberCount}}</span>
|
||||
{{/unless}}
|
||||
{{#let (members-count-fetcher) as |count|}}
|
||||
{{#unless count.isLoading}}
|
||||
<span class="gh-nav-member-count">{{format-number count.count}}</span>
|
||||
{{/unless}}
|
||||
{{/let}}
|
||||
</LinkTo>
|
||||
{{else}}
|
||||
<LinkTo @route="members" @current-when="members member member.new" data-test-nav="members">{{svg-jar "members"}}Members
|
||||
{{#unless this.memberCountLoading}}
|
||||
<span class="gh-nav-member-count">{{format-number this.membersStats.memberCount}}</span>
|
||||
{{/unless}}
|
||||
{{#let (members-count-fetcher) as |count|}}
|
||||
{{#unless count.isLoading}}
|
||||
<span class="gh-nav-member-count">{{format-number count.count}}</span>
|
||||
{{/unless}}
|
||||
{{/let}}
|
||||
</LinkTo>
|
||||
{{/if}}
|
||||
</li>
|
||||
|
@ -10,7 +10,6 @@ import {htmlSafe} from '@ember/template';
|
||||
import {inject} from 'ghost-admin/decorators/inject';
|
||||
import {inject as service} from '@ember/service';
|
||||
import {tagName} from '@ember-decorators/component';
|
||||
import {task} from 'ember-concurrency';
|
||||
|
||||
@classic
|
||||
@tagName('')
|
||||
@ -33,7 +32,6 @@ export default class Main extends Component.extend(ShortcutsMixin) {
|
||||
|
||||
iconStyle = '';
|
||||
iconClass = '';
|
||||
memberCountLoading = true;
|
||||
shortcuts = null;
|
||||
|
||||
@match('router.currentRouteName', /^settings\.integration/)
|
||||
@ -69,10 +67,6 @@ export default class Main extends Component.extend(ShortcutsMixin) {
|
||||
didReceiveAttrs() {
|
||||
super.didReceiveAttrs(...arguments);
|
||||
this._setIconStyle();
|
||||
|
||||
if (this.session.user && this.session.user.isAdmin) {
|
||||
this._loadMemberCountsTask.perform();
|
||||
}
|
||||
}
|
||||
|
||||
didInsertElement() {
|
||||
@ -114,17 +108,6 @@ export default class Main extends Component.extend(ShortcutsMixin) {
|
||||
this.explore.openExploreWindow();
|
||||
}
|
||||
|
||||
@task(function* () {
|
||||
try {
|
||||
this.set('memberCountLoading', true);
|
||||
yield this.membersStats.fetchMemberCount();
|
||||
this.set('memberCountLoading', false);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
_loadMemberCountsTask;
|
||||
|
||||
_setIconStyle() {
|
||||
let icon = this.icon;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user