mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 11:55:03 +03:00
🐛 Fix sidebar members number not updated after member create & delete (#15378)
no issue Dynamically updates member count on the sidebar when creating, deleting and uploading members.
This commit is contained in:
parent
8935f53d63
commit
f133c85258
@ -94,13 +94,13 @@
|
||||
{{#if (eq this.router.currentRouteName "members.index")}}
|
||||
<LinkTo @route="members" @current-when="members member" @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.memberCount}}</span>
|
||||
<span class="gh-nav-member-count">{{format-number this.membersStats.memberCount}}</span>
|
||||
{{/unless}}
|
||||
</LinkTo>
|
||||
{{else}}
|
||||
<LinkTo @route="members" @current-when="members member" data-test-nav="members">{{svg-jar "members"}}Members
|
||||
{{#unless this.memberCountLoading}}
|
||||
<span class="gh-nav-member-count">{{format-number this.memberCount}}</span>
|
||||
<span class="gh-nav-member-count">{{format-number this.membersStats.memberCount}}</span>
|
||||
{{/unless}}
|
||||
</LinkTo>
|
||||
{{/if}}
|
||||
|
@ -31,7 +31,6 @@ export default class Main extends Component.extend(ShortcutsMixin) {
|
||||
iconStyle = '';
|
||||
iconClass = '';
|
||||
memberCountLoading = true;
|
||||
memberCount = 0;
|
||||
shortcuts = null;
|
||||
|
||||
@match('router.currentRouteName', /^settings\.integration/)
|
||||
@ -110,13 +109,8 @@ export default class Main extends Component.extend(ShortcutsMixin) {
|
||||
@task(function* () {
|
||||
try {
|
||||
this.set('memberCountLoading', true);
|
||||
const stats = yield this.membersStats.fetchMemberCount();
|
||||
yield this.membersStats.fetchMemberCount();
|
||||
this.set('memberCountLoading', false);
|
||||
if (stats) {
|
||||
const {free, paid, comped} = stats.meta.totals;
|
||||
const total = free + paid + comped || 0;
|
||||
this.set('memberCount', total);
|
||||
}
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
|
@ -234,6 +234,7 @@ export default class MembersController extends Controller {
|
||||
this.fetchLabelsTask.perform();
|
||||
this.membersStats.invalidate();
|
||||
this.membersStats.fetchCounts();
|
||||
this.membersStats.fetchMemberCount();
|
||||
}
|
||||
|
||||
@action
|
||||
|
@ -18,6 +18,16 @@ export default class MembersStatsService extends Service {
|
||||
@tracked newsletterStats = null;
|
||||
@tracked totalMemberCount = null;
|
||||
|
||||
get memberCount() {
|
||||
let stats = this.totalMemberCount;
|
||||
if (!stats) {
|
||||
return 0;
|
||||
}
|
||||
const {free, paid, comped} = stats.meta.totals;
|
||||
const total = free + paid + comped || 0;
|
||||
return total;
|
||||
}
|
||||
|
||||
fetch() {
|
||||
let daysChanged = this._lastFetchedDays !== this.days;
|
||||
let staleData = this._lastFetched && (new Date() - this._lastFetched) > ONE_MINUTE;
|
||||
|
Loading…
Reference in New Issue
Block a user