From 3b81aabe9b2a87758ffa10b3f78fe3655c5683f1 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Wed, 30 Sep 2020 16:33:10 -0400 Subject: [PATCH] Improve `PostStreamState.viewingEnd()` In some cases, such as if we've stickied a post, an event post may have been added / removed.This means that `this.visibleEnd` and`this.count()` will be out of sync by 1 post, but we are still "viewing the end" of the post stream, so we should still reload all posts up until the last one. --- framework/core/js/src/forum/states/PostStreamState.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/framework/core/js/src/forum/states/PostStreamState.js b/framework/core/js/src/forum/states/PostStreamState.js index 277fd4959..2c827bff3 100644 --- a/framework/core/js/src/forum/states/PostStreamState.js +++ b/framework/core/js/src/forum/states/PostStreamState.js @@ -344,7 +344,12 @@ class PostStreamState { * @return {boolean} */ viewingEnd() { - return this.visibleEnd === this.count(); + // In some cases, such as if we've stickied a post, an event post + // may have been added / removed. This means that `this.visibleEnd` + // and`this.count()` will be out of sync by 1 post, but we are still + // "viewing the end" of the post stream, so we should still reload + // all posts up until the last one. + return Math.abs(this.count() - this.visibleEnd) <= 1; } /**