mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
a0ec07f797
closes #5630 - upgrade ember-cli to latest version - upgrade ember to latest 1.13.x release - upgrade ember data to latest 1.13.x release - update custom adapters and serialisers for new internal JSON-API compatible formats [(docs)][1] - update all store queries to use new standardised query methods [(docs)][2] - add ember-data-filter addon ready for store.filter removal in ember-data 2.0 [(docs)][3] - remove use of prototype extensions for computed properties and observers - consolidate pagination into a single route mixin and simplify configuration [1]: http://emberjs.com/blog/2015/06/18/ember-data-1-13-released.html#toc_transition-to-the-new-jsonserializer-and-restserializer-apis [2]: http://emberjs.com/blog/2015/06/18/ember-data-1-13-released.html#toc_simplified-find-methods [3]: http://emberjs.com/blog/2015/06/18/ember-data-1-13-released.html#toc_ds-store-filter-moved-to-an-addon
48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
|
import MobileIndexRoute from 'ghost/routes/mobile-index-route';
|
|
import mobileQuery from 'ghost/utils/mobile';
|
|
|
|
export default MobileIndexRoute.extend(AuthenticatedRouteMixin, {
|
|
noPosts: false,
|
|
|
|
// Transition to a specific post if we're not on mobile
|
|
beforeModel: function () {
|
|
if (!mobileQuery.matches) {
|
|
return this.goToPost();
|
|
}
|
|
},
|
|
|
|
setupController: function (controller, model) {
|
|
/*jshint unused:false*/
|
|
controller.set('noPosts', this.get('noPosts'));
|
|
},
|
|
|
|
goToPost: function () {
|
|
var self = this,
|
|
// the store has been populated by PostsRoute
|
|
posts = this.store.peekAll('post'),
|
|
post;
|
|
|
|
return this.get('session.user').then(function (user) {
|
|
post = posts.find(function (post) {
|
|
// Authors can only see posts they've written
|
|
if (user.get('isAuthor')) {
|
|
return post.isAuthoredByUser(user);
|
|
}
|
|
|
|
return true;
|
|
});
|
|
|
|
if (post) {
|
|
return self.transitionTo('posts.post', post);
|
|
}
|
|
|
|
self.set('noPosts', true);
|
|
});
|
|
},
|
|
|
|
// Mobile posts route callback
|
|
desktopTransition: function () {
|
|
this.goToPost();
|
|
}
|
|
});
|