From c65581d378b6ac906da939688a915c6c0495ad55 Mon Sep 17 00:00:00 2001 From: David Arvelo Date: Thu, 5 Jun 2014 13:23:28 -0400 Subject: [PATCH] Fix Editor/:postId 404 on draft 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'}` --- core/client/routes/editor.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/client/routes/editor.js b/core/client/routes/editor.js index fa33e62dcd..5895492b1f 100644 --- a/core/client/routes/editor.js +++ b/core/client/routes/editor.js @@ -5,7 +5,17 @@ var EditorRoute = AuthenticatedRoute.extend(styleBody, { classNames: ['editor'], controllerName: 'posts.post', model: function (params) { - return this.store.find('post', params.post_id); + 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'); + }); } });