From 4ade6138d3f94ef2b1318691c80d9a4fcf0096ca Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Mon, 5 Oct 2015 16:09:18 +1100 Subject: [PATCH] FIX: suggested topics showing up when last post not loaded New fix means that was show suggested 1. If all posts are loaded 2. If we are in the process of loading 1 more post due to message bus --- .../discourse/controllers/topic.js.es6 | 18 +----------------- .../discourse/models/post-stream.js.es6 | 7 ++++++- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6 index 70f3a967a..8a6c7b228 100644 --- a/app/assets/javascripts/discourse/controllers/topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -15,7 +15,7 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, { selectedPosts: null, selectedReplies: null, queryParams: ['filter', 'username_filters', 'show_deleted'], - loadedAllPosts: false, + loadedAllPosts: Em.computed.or('model.postStream.loadedAllPosts', 'model.postStream.loadingLastPost'), enteredAt: null, firstPostExpanded: false, retrying: false, @@ -36,22 +36,6 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, { } }.observes('model.title', 'category'), - postStreamLoadedAllPostsChanged: function() { - // semantics of loaded all posts are slightly diff at topic level, - // it just means that we "once" loaded all posts, this means we don't - // keep re-rendering the suggested topics when new posts zoom in - let loaded = this.get('model.postStream.loadedAllPosts'); - - if (loaded) { - this.set('model.loadedTopicId', this.get('model.id')); - } else { - loaded = this.get('model.loadedTopicId') === this.get('model.id'); - } - - this.set('loadedAllPosts', loaded); - - }.observes('model.postStream', 'model.postStream.loadedAllPosts'), - @computed('model.postStream.summary') show_deleted: { set(value) { diff --git a/app/assets/javascripts/discourse/models/post-stream.js.es6 b/app/assets/javascripts/discourse/models/post-stream.js.es6 index d810723ac..010330451 100644 --- a/app/assets/javascripts/discourse/models/post-stream.js.es6 +++ b/app/assets/javascripts/discourse/models/post-stream.js.es6 @@ -464,7 +464,12 @@ const PostStream = RestModel.extend({ if (this.get('stream').indexOf(postId) === -1) { this.get('stream').addObject(postId); - if (loadedAllPosts) { this.appendMore(); } + if (loadedAllPosts) { + this.set('loadingLastPost', true); + this.appendMore().finally( + ()=>this.set('loadingLastPost', true) + ); + } } },