A platform for community discussion. Free, open, simple.
FEATURE: load hidden posts in segments (#10240)
Krzysztof Kotlarek9052dfe356a5
diff --git a/app/assets/javascripts/discourse/app/models/post-stream.js b/app/assets/javascripts/discourse/app/models/post-stream.jsindex 2c56f8ef8ae..37b077c9500 100644--- a/app/assets/javascripts/discourse/app/models/post-stream.js+++ b/app/assets/javascripts/discourse/app/models/post-stream.js@@ -304,8 +304,11 @@ export default RestModel.extend({let postIdx = currentPosts.indexOf(post);const origIdx = postIdx;++ let headGap = gap.slice(0, this.topic.chunk_size);+ let tailGap = gap.slice(this.topic.chunk_size);if (postIdx !== -1) {- return this.findPostsByIds(gap).then(posts => {+ return this.findPostsByIds(headGap).then(posts => {posts.forEach(p => {const stored = this.storePost(p);if (!currentPosts.includes(stored)) {@@ -313,7 +316,11 @@ export default RestModel.extend({}});- delete this.get("gaps.before")[postId];+ if (tailGap.length > 0) {+ this.get("gaps.before")[postId] = tailGap;+ } else {+ delete this.get("gaps.before")[postId];+ }this.stream.arrayContentDidChange();this.postsWithPlaceholders.arrayContentDidChange(origIdx,diff --git a/app/assets/javascripts/discourse/app/widgets/post-gap.js b/app/assets/javascripts/discourse/app/widgets/post-gap.jsindex e4ba009147b..481d0efe05e 100644--- a/app/assets/javascripts/discourse/app/widgets/post-gap.js+++ b/app/assets/javascripts/discourse/app/widgets/post-gap.js@@ -27,6 +27,8 @@ export default createWidget("post-gap", {return this.sendWidgetAction(attrs.pos === "before" ? "fillGapBefore" : "fillGapAfter",args- );+ ).then(() => {+ state.loading = false;+ });}});