From 81a0b25324165f603325f05f780469760f5a0908 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 8 Feb 2016 12:48:48 -0500 Subject: [PATCH] FIX: `postChangedRoute` was firing after destruction sometimes --- .../javascripts/discourse/controllers/topic.js.es6 | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6 index b4bb45fd087..7f91beeb192 100644 --- a/app/assets/javascripts/discourse/controllers/topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -122,7 +122,9 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, { const postStream = this.get('model.postStream'); const firstLoadedPost = postStream.get('posts.firstObject'); - this.set('model.currentPost', post.get('post_number')); + const currentPostNumber = post.get('post_number'); + this.set('model.currentPost', currentPostNumber); + this.send('postChangedRoute', currentPostNumber); if (post.get('post_number') === 1) { return; } @@ -712,14 +714,6 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, { } }, - // If our current post is changed, notify the router - _currentPostChanged: function() { - const currentPost = this.get('model.currentPost'); - if (currentPost) { - this.send('postChangedRoute', currentPost); - } - }.observes('model.currentPost'), - readPosts(topicId, postNumbers) { const topic = this.get("model"), postStream = topic.get("postStream");