Ghost/ghost/admin/app/services/mention-utils.js
Rishabh Garg ef538428c9
Fixed broken empty state in mentions admin url (#16419)
fixes https://github.com/TryGhost/Team/issues/2734

With WebMentions flag on, navigating to `/ghost/#/mentions` on Admin when there are no mentions gives a 400 error page instead of the intended empty state.
2023-03-16 21:19:56 +05:30

21 lines
673 B
JavaScript

import Service, {inject as service} from '@ember/service';
export default class MentionUtilsService extends Service {
@service store;
async loadGroupedMentions(mentions) {
// Fetch mentions with the same source
const sources = mentions.mapBy('source').uniq();
let filter;
if (sources.length > 0) {
filter = `source:[${sources.map(s => `'${s}'`).join(',')}]`;
}
const sourceMentions = await this.store.query('mention', {filter});
mentions.forEach((mention) => {
mention.set('mentions', sourceMentions.filterBy('source', mention.source));
});
return mentions;
}
}