mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 10:21:36 +03:00
4b3fc52cf0
refs https://github.com/TryGhost/Team/issues/1277 - first step of further refactoring to make member activity display more generic - separates component data loading from overall controller logic and allows it to be tested in integration tests as well as acceptance tests
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
import Component from '@glimmer/component';
|
|
import {inject as service} from '@ember/service';
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
export default class DashboardLatestMemberActivityComponent extends Component {
|
|
@service membersActivity;
|
|
@service session;
|
|
@service settings;
|
|
|
|
@tracked eventsData = null;
|
|
@tracked eventsError = null;
|
|
@tracked eventsLoading = false;
|
|
|
|
get shouldDisplay() {
|
|
const isOwner = this.session.user?.isOwnerOnly;
|
|
const hasCompletedLaunchWizard = this.settings.get('editorIsLaunchComplete');
|
|
|
|
console.log(this.session.user, {isOwner, hasCompletedLaunchWizard});
|
|
|
|
if (isOwner && !hasCompletedLaunchWizard) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
constructor() {
|
|
super(...arguments);
|
|
|
|
if (this.shouldDisplay) {
|
|
this.loadEvents();
|
|
}
|
|
}
|
|
|
|
async loadEvents() {
|
|
try {
|
|
this.eventsLoading = true;
|
|
const {events} = await this.membersActivity.fetchTimeline({limit: 5});
|
|
this.eventsData = events;
|
|
} catch (error) {
|
|
this.eventsError = error;
|
|
} finally {
|
|
this.eventsLoading = false;
|
|
}
|
|
}
|
|
}
|