mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 03:12:54 +03:00
8cc4c6c4a1
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
32 lines
952 B
JavaScript
32 lines
952 B
JavaScript
import Component from '@glimmer/component';
|
|
import {inject as service} from '@ember/service';
|
|
import {task} from 'ember-concurrency';
|
|
|
|
export default class DeletePostModalComponent extends Component {
|
|
@service notifications;
|
|
@service router;
|
|
|
|
@task({drop: true})
|
|
*deletePostTask() {
|
|
try {
|
|
const {post} = this.args.data;
|
|
|
|
if (post.isDeleted) {
|
|
return true;
|
|
}
|
|
|
|
// clear the data store and post of any unsaved client-generated tags before deleting
|
|
post.updateTags();
|
|
yield post.destroyRecord();
|
|
|
|
this.notifications.closeAlerts('post.delete');
|
|
this.router.transitionTo(post.displayName === 'page' ? 'pages' : 'posts');
|
|
return true;
|
|
} catch (error) {
|
|
this.notifications.showAPIError(error, {key: 'post.delete.failed'});
|
|
} finally {
|
|
this.args.close();
|
|
}
|
|
}
|
|
}
|