mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 22:02:11 +03:00
eeedc2f1dc
closes TryGhost/Ghost#8287 closes TryGhost/Ghost#8750 - moved all editor model functionality into the new `editor` route+controller - moved editor template from `editor/edit.hbs` to `editor.hbs` - refactored `editor` controller and the `editor.new`/`editor.edit` routes to work with a persistent editor rather than a teardown/re-render when transitioning from new->edit - fixed issue in `{{gh-markdown-editor}}` for `autofocus` behaviour when the component isn't re-rendered - fixed issue in `{{gh-simplemde}}` that was causing multiple updates to the `value` property when a new value is passed in to the component - added `{{gh-scheduled-post-countdown}}` component to lower the noise in the editor controller - removed editor route/controller mixins - removed the `editor.edit` and `editor.new` controllers
29 lines
978 B
JavaScript
29 lines
978 B
JavaScript
import Component from '@ember/component';
|
|
import moment from 'moment';
|
|
import {computed} from '@ember/object';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default Component.extend({
|
|
clock: service(),
|
|
|
|
post: null,
|
|
|
|
// countdown timer to show the time left until publish time for a scheduled post
|
|
// starts 15 minutes before scheduled time
|
|
countdown: computed('post.{publishedAtUTC,isScheduled}', 'clock.second', function () {
|
|
let isScheduled = this.get('post.isScheduled');
|
|
let publishTime = this.get('post.publishedAtUTC') || moment.utc();
|
|
let timeUntilPublished = publishTime.diff(moment.utc(), 'minutes', true);
|
|
let isPublishedSoon = timeUntilPublished > 0 && timeUntilPublished < 15;
|
|
|
|
// force a recompute
|
|
this.get('clock.second');
|
|
|
|
if (isScheduled && isPublishedSoon) {
|
|
return moment(publishTime).fromNow();
|
|
} else {
|
|
return false;
|
|
}
|
|
})
|
|
});
|