From 8a9e50d192ac62504671c169312f833ecd21517d Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 3 Jul 2020 22:09:26 +0200 Subject: [PATCH] Encapsulate viewingEnd() in state ...instead of calculating this derived value outside the state class. --- js/src/forum/components/PostStream.js | 6 +++--- js/src/forum/states/PostStreamState.js | 11 ++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/js/src/forum/components/PostStream.js b/js/src/forum/components/PostStream.js index 2db6d0d23..93beb7469 100644 --- a/js/src/forum/components/PostStream.js +++ b/js/src/forum/components/PostStream.js @@ -45,7 +45,7 @@ export default class PostStream extends Component { let lastTime; this.state.visibleEnd = this.state.sanitizeIndex(this.state.visibleEnd); - this.state.viewingEnd = this.state.visibleEnd === this.state.count(); + const viewingEnd = this.state.viewingEnd(); const posts = this.state.posts(); const postIds = this.state.discussion.postIds(); @@ -94,7 +94,7 @@ export default class PostStream extends Component { ); }); - if (!this.state.viewingEnd && posts[this.state.visibleEnd - this.state.visibleStart - 1]) { + if (!viewingEnd && posts[this.state.visibleEnd - this.state.visibleStart - 1]) { items.push(