mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Only load posts once on navigating to content tab
No Issue - Loading posts from the API should not be necessary in PostsIndexRoute because its parent resource (PostsRoute) pre-loads the store. Changing the store.find to store.all gets rid of a duplicate network request to load all posts.
This commit is contained in:
parent
1caa5bd6e0
commit
1c356f59b2
1 changed files with 8 additions and 12 deletions
|
@ -1,20 +1,16 @@
|
||||||
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
||||||
|
|
||||||
var PostsIndexRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, loadingIndicator, {
|
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 () {
|
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', {
|
if (post) {
|
||||||
status: 'all',
|
return this.transitionTo('posts.post', post);
|
||||||
staticPages: 'all',
|
}
|
||||||
}).then(function (records) {
|
|
||||||
var post = records.get('firstObject');
|
|
||||||
|
|
||||||
if (post) {
|
|
||||||
return self.transitionTo('posts.post', post);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue