Ghost/ghost/admin/app/components/gh-members-no-members.js
Kevin Ansfield 8cc4c6c4a1 Dropped ember-concurrency-decorators dependency
no issue

- since `ember-concurrency@2.0` it's possible to use the standard imports as decorators removing the need for the extra `ember-concurrency-decorators` dependency and imports
2022-02-09 10:49:38 +00:00

46 lines
1.1 KiB
JavaScript

import Component from '@glimmer/component';
import {action} from '@ember/object';
import {inject as service} from '@ember/service';
import {task} from 'ember-concurrency';
export default class GhMembersNoMembersComponent extends Component {
@service session;
@service store;
@service notifications;
@action
addYourself() {
return this.addTask.perform();
}
@task({drop: true})
*addTask() {
const user = yield this.session.user;
const member = this.store.createRecord('member', {
email: user.get('email'),
name: user.get('name')
});
try {
yield member.save();
if (this.args.afterCreate) {
this.args.afterCreate();
}
this.notifications.showNotification('Member added',
{
description: 'You\'ve successfully added yourself as a member.'
}
);
return member;
} catch (error) {
if (error) {
this.notifications.showAPIError(error, {key: 'member.save'});
}
}
}
}