2021-09-08 16:29:33 +03:00
|
|
|
import Component from '@glimmer/component';
|
|
|
|
import {action} from '@ember/object';
|
2021-11-09 15:12:46 +03:00
|
|
|
import {task} from 'ember-concurrency-decorators';
|
2021-09-08 16:29:33 +03:00
|
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
|
|
|
|
export default class ModalPostPreviewComponent extends Component {
|
|
|
|
@tracked tab = 'browser';
|
|
|
|
|
2021-11-09 15:12:46 +03:00
|
|
|
constructor() {
|
|
|
|
super(...arguments);
|
|
|
|
this.saveFirstTask.perform();
|
|
|
|
}
|
|
|
|
|
2021-09-08 16:29:33 +03:00
|
|
|
@action
|
|
|
|
changeTab(tab) {
|
|
|
|
this.tab = tab;
|
|
|
|
}
|
2021-11-09 15:12:46 +03:00
|
|
|
|
|
|
|
@task
|
|
|
|
*saveFirstTask() {
|
|
|
|
const {saveTask, post, hasDirtyAttributes} = this.args.data;
|
|
|
|
|
|
|
|
if (saveTask.isRunning) {
|
|
|
|
return yield saveTask.last;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (post.isDraft && hasDirtyAttributes) {
|
|
|
|
yield saveTask.perform();
|
|
|
|
}
|
|
|
|
}
|
2021-09-08 16:29:33 +03:00
|
|
|
}
|