mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-12 16:14:25 +03:00
Merge pull request #3347 from jaswilli/posts-content
Only load posts once on navigating to content tab
This commit is contained in:
commit
5b41358e45
@ -1,20 +1,16 @@
|
||||
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
||||
|
||||
var PostsIndexRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, loadingIndicator, {
|
||||
// redirect to first post subroute unless no posts exist
|
||||
// This route's only function is to determine whether or not a post
|
||||
// exists to be used for the content preview. It has a parent resource (Posts)
|
||||
// that is responsible for populating the store.
|
||||
beforeModel: function () {
|
||||
var self = this;
|
||||
// the store has been populated so we can work with the local copy
|
||||
var post = this.store.all('post').get('firstObject');
|
||||
|
||||
return this.store.find('post', {
|
||||
status: 'all',
|
||||
staticPages: 'all',
|
||||
}).then(function (records) {
|
||||
var post = records.get('firstObject');
|
||||
|
||||
if (post) {
|
||||
return self.transitionTo('posts.post', post);
|
||||
}
|
||||
});
|
||||
if (post) {
|
||||
return this.transitionTo('posts.post', post);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user