diff --git a/ghost/admin/app/components/members-activity/table.hbs b/ghost/admin/app/components/members-activity/table.hbs
index 18a2865f76..6633cbb935 100644
--- a/ghost/admin/app/components/members-activity/table.hbs
+++ b/ghost/admin/app/components/members-activity/table.hbs
@@ -10,7 +10,7 @@
{{#each @events as |event|}}
-
+
{{/each}}
diff --git a/ghost/admin/app/helpers/members-event-fetcher.js b/ghost/admin/app/helpers/members-event-fetcher.js
index b3e4663346..4c45a1d892 100644
--- a/ghost/admin/app/helpers/members-event-fetcher.js
+++ b/ghost/admin/app/helpers/members-event-fetcher.js
@@ -9,6 +9,7 @@ import {tracked} from '@glimmer/tracking';
export default class MembersEventsFetcher extends Resource {
@service ajax;
@service ghostPaths;
+ @service store;
@tracked data = new TrackedArray([]);
@tracked isLoading = false;
@@ -16,6 +17,11 @@ export default class MembersEventsFetcher extends Resource {
@tracked errorMessage = null;
@tracked hasReachedEnd = false;
+ /**
+ * Keep track whether we have multiple newsletters (required for parsing events)
+ */
+ @tracked hasMultipleNewsletters = null;
+
cursor = null;
get value() {
@@ -25,7 +31,8 @@ export default class MembersEventsFetcher extends Resource {
errorMessage: this.errorMessage,
data: this.data,
loadNextPage: this.loadNextPage,
- hasReachedEnd: this.hasReachedEnd
+ hasReachedEnd: this.hasReachedEnd,
+ hasMultipleNewsletters: this.hasMultipleNewsletters
};
}
@@ -37,7 +44,9 @@ export default class MembersEventsFetcher extends Resource {
filter += `+${this.args.named.filter}`;
}
- return this.loadEventsTask.perform({filter});
+ // Can't get this working with Promise.all, somehow results in an infinite loop
+ await this.loadEventsTask.perform({filter});
+ await this.loadMultipleNewslettersTask.perform();
}
@action
@@ -67,6 +76,22 @@ export default class MembersEventsFetcher extends Resource {
this.loadEventsTask.perform({filter});
}
+ /**
+ * We need to know whether we have multiple newsletters so we can hide/show the newsletter name
+ */
+ @task
+ *loadMultipleNewslettersTask() {
+ try {
+ const res = yield this.store.query('newsletter', {filter: 'status:active', include: 'none', limit: 1});
+ const newsletterCount = res.meta.pagination.total;
+ this.hasMultipleNewsletters = newsletterCount > 1;
+ } catch (e) {
+ // Default to true (harms the least)
+ this.hasMultipleNewsletters = true;
+ console.error(e); // eslint-disable-line
+ }
+ }
+
@task
*loadEventsTask(queryParams) {
try {
diff --git a/ghost/admin/app/helpers/parse-member-event.js b/ghost/admin/app/helpers/parse-member-event.js
index 9bba361304..71f27b4588 100644
--- a/ghost/admin/app/helpers/parse-member-event.js
+++ b/ghost/admin/app/helpers/parse-member-event.js
@@ -1,11 +1,11 @@
import moment from 'moment';
import {getNonDecimal, getSymbol} from 'ghost-admin/utils/currency';
-export default function parseMemberEvent(event) {
+export default function parseMemberEvent(event, hasMultipleNewsletters) {
let subject = event.data.member.name || event.data.member.email;
let icon = getIcon(event);
let action = getAction(event);
- let object = getObject(event);
+ let object = getObject(event, hasMultipleNewsletters);
let info = getInfo(event);
let timestamp = moment(event.data.created_at);
@@ -125,12 +125,12 @@ function getAction(event) {
}
}
-function getObject(event) {
+function getObject(event, hasMultipleNewsletters) {
if (event.type === 'newsletter_event') {
- if (event.data.newsletter && event.data.newsletter.name) {
+ if (hasMultipleNewsletters && event.data.newsletter && event.data.newsletter.name) {
return 'newsletter – ' + event.data.newsletter.name;
}
- return 'emails';
+ return 'newsletter';
}
if (event.type === 'subscription_event') {
diff --git a/ghost/admin/app/templates/members-activity.hbs b/ghost/admin/app/templates/members-activity.hbs
index a23b674d65..fdfd5f1ac2 100644
--- a/ghost/admin/app/templates/members-activity.hbs
+++ b/ghost/admin/app/templates/members-activity.hbs
@@ -26,7 +26,7 @@
{{/if}}
-
+
{{#if (not (or eventsFetcher.isLoading eventsFetcher.hasReachedEnd))}}
@@ -45,4 +45,4 @@
-{{outlet}}
\ No newline at end of file
+{{outlet}}