2017-08-22 10:53:26 +03:00
|
|
|
import Component from '@ember/component';
|
2018-05-03 19:52:39 +03:00
|
|
|
import config from 'ghost-admin/config/environment';
|
2017-05-29 21:50:03 +03:00
|
|
|
import {task, timeout} from 'ember-concurrency';
|
2017-04-11 16:39:45 +03:00
|
|
|
|
|
|
|
export default Component.extend({
|
|
|
|
post: null,
|
|
|
|
isSaving: false,
|
|
|
|
|
|
|
|
'data-test-editor-post-status': true,
|
|
|
|
|
|
|
|
_isSaving: false,
|
|
|
|
|
|
|
|
// isSaving will only be true briefly whilst the post is saving,
|
|
|
|
// we want to ensure that the "Saving..." message is shown for at least
|
|
|
|
// a few seconds so that it's noticeable
|
|
|
|
didReceiveAttrs() {
|
2019-03-06 16:53:54 +03:00
|
|
|
if (this.isSaving) {
|
|
|
|
this.showSavingMessage.perform();
|
2017-04-11 16:39:45 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
showSavingMessage: task(function* () {
|
|
|
|
this.set('_isSaving', true);
|
2018-05-03 19:52:39 +03:00
|
|
|
yield timeout(config.environment === 'test' ? 0 : 3000);
|
2017-04-11 16:39:45 +03:00
|
|
|
this.set('_isSaving', false);
|
|
|
|
}).drop()
|
|
|
|
});
|