mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
c65581d378
closes #2857 - in EditorRoute, get model from the datastore if it's there - if page is refreshed, get model from `/posts` API with `{status: 'all'}`
22 lines
648 B
JavaScript
22 lines
648 B
JavaScript
import styleBody from 'ghost/mixins/style-body';
|
|
import AuthenticatedRoute from 'ghost/routes/authenticated';
|
|
|
|
var EditorRoute = AuthenticatedRoute.extend(styleBody, {
|
|
classNames: ['editor'],
|
|
controllerName: 'posts.post',
|
|
model: function (params) {
|
|
var post = this.store.getById('post', params.post_id);
|
|
|
|
if (post) {
|
|
return post;
|
|
}
|
|
|
|
return this.store.filter('post', { status: 'all' }, function (post) {
|
|
return post.get('id') === params.post_id;
|
|
}).then(function (records) {
|
|
return records.get('firstObject');
|
|
});
|
|
}
|
|
});
|
|
|
|
export default EditorRoute;
|