mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 20:03:12 +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")}}
|
{{#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
|
<LinkTo @route="members" @current-when="members member" @query={{reset-query-params "members.index"}} data-test-nav="members">{{svg-jar "members"}}Members
|
||||||
{{#unless this.memberCountLoading}}
|
{{#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}}
|
{{/unless}}
|
||||||
</LinkTo>
|
</LinkTo>
|
||||||
{{else}}
|
{{else}}
|
||||||
<LinkTo @route="members" @current-when="members member" data-test-nav="members">{{svg-jar "members"}}Members
|
<LinkTo @route="members" @current-when="members member" data-test-nav="members">{{svg-jar "members"}}Members
|
||||||
{{#unless this.memberCountLoading}}
|
{{#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}}
|
{{/unless}}
|
||||||
</LinkTo>
|
</LinkTo>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
@ -31,7 +31,6 @@ export default class Main extends Component.extend(ShortcutsMixin) {
|
|||||||
iconStyle = '';
|
iconStyle = '';
|
||||||
iconClass = '';
|
iconClass = '';
|
||||||
memberCountLoading = true;
|
memberCountLoading = true;
|
||||||
memberCount = 0;
|
|
||||||
shortcuts = null;
|
shortcuts = null;
|
||||||
|
|
||||||
@match('router.currentRouteName', /^settings\.integration/)
|
@match('router.currentRouteName', /^settings\.integration/)
|
||||||
@ -110,13 +109,8 @@ export default class Main extends Component.extend(ShortcutsMixin) {
|
|||||||
@task(function* () {
|
@task(function* () {
|
||||||
try {
|
try {
|
||||||
this.set('memberCountLoading', true);
|
this.set('memberCountLoading', true);
|
||||||
const stats = yield this.membersStats.fetchMemberCount();
|
yield this.membersStats.fetchMemberCount();
|
||||||
this.set('memberCountLoading', false);
|
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) {
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -234,6 +234,7 @@ export default class MembersController extends Controller {
|
|||||||
this.fetchLabelsTask.perform();
|
this.fetchLabelsTask.perform();
|
||||||
this.membersStats.invalidate();
|
this.membersStats.invalidate();
|
||||||
this.membersStats.fetchCounts();
|
this.membersStats.fetchCounts();
|
||||||
|
this.membersStats.fetchMemberCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
@ -18,6 +18,16 @@ export default class MembersStatsService extends Service {
|
|||||||
@tracked newsletterStats = null;
|
@tracked newsletterStats = null;
|
||||||
@tracked totalMemberCount = 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() {
|
fetch() {
|
||||||
let daysChanged = this._lastFetchedDays !== this.days;
|
let daysChanged = this._lastFetchedDays !== this.days;
|
||||||
let staleData = this._lastFetched && (new Date() - this._lastFetched) > ONE_MINUTE;
|
let staleData = this._lastFetched && (new Date() - this._lastFetched) > ONE_MINUTE;
|
||||||
|
Loading…
Reference in New Issue
Block a user