mirror of
https://github.com/discourse/discourse.git
synced 2025-02-21 01:40:40 +08:00
FEATURE: load hidden posts in segments (#10240)
* FEATURE: load hidden posts in segments Currently, when "View hidden replies" button is clicked, all replies are loaded like there is no tomorrow. When there is plenty of hidden replies, it may cause a timeout. Therefore, we should load them in pages and display the view link as long as we have more hidden replies.
This commit is contained in:
parent
34bbd51350
commit
9052dfe356
@ -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,
|
||||
|
@ -27,6 +27,8 @@ export default createWidget("post-gap", {
|
||||
return this.sendWidgetAction(
|
||||
attrs.pos === "before" ? "fillGapBefore" : "fillGapAfter",
|
||||
args
|
||||
);
|
||||
).then(() => {
|
||||
state.loading = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user