mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-07 03:22:21 +03:00
c09dcd38af
refs https://github.com/TryGhost/Team/issues/609 There's a 3 second timeout before a background save is triggered after the last edit, if the preview modal is opened in that timeframe it would show outdated content. - added a task that is triggered when the preview modal is opened - if a save task is already running it will wait for it to finish - otherwise if the post is a draft and the editor has dirty attributes it will trigger a save - modal shows a loading spinner whilst waiting for the save to finish so the preview contents always match the latest editor changes
32 lines
727 B
JavaScript
32 lines
727 B
JavaScript
import Component from '@glimmer/component';
|
|
import {action} from '@ember/object';
|
|
import {task} from 'ember-concurrency-decorators';
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
export default class ModalPostPreviewComponent extends Component {
|
|
@tracked tab = 'browser';
|
|
|
|
constructor() {
|
|
super(...arguments);
|
|
this.saveFirstTask.perform();
|
|
}
|
|
|
|
@action
|
|
changeTab(tab) {
|
|
this.tab = tab;
|
|
}
|
|
|
|
@task
|
|
*saveFirstTask() {
|
|
const {saveTask, post, hasDirtyAttributes} = this.args.data;
|
|
|
|
if (saveTask.isRunning) {
|
|
return yield saveTask.last;
|
|
}
|
|
|
|
if (post.isDraft && hasDirtyAttributes) {
|
|
yield saveTask.perform();
|
|
}
|
|
}
|
|
}
|