This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor new->edit transition to avoid editor re-renders
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
- Loading branch information
1 parent
5a54a60
commit 2ce3f57
Showing
16 changed files
with
919 additions
and
963 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
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; | ||
} | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.