diff --git a/js/src/forum/components/PostStream.js b/js/src/forum/components/PostStream.js index c121b37ca88..cf5a43d1ceb 100644 --- a/js/src/forum/components/PostStream.js +++ b/js/src/forum/components/PostStream.js @@ -146,12 +146,10 @@ export default class PostStream extends Component { * @param {Integer} top */ onscroll(top = window.pageYOffset) { - if (this.stream.paused) return; + if (this.stream.paused || this.stream.pagesLoading) return; this.updateScrubber(top); - if (this.stream.pagesLoading) return; - this.loadPostsIfNeeded(top); // Throttle calculation of our position (start/end numbers of posts in the diff --git a/js/src/forum/states/PostStreamState.js b/js/src/forum/states/PostStreamState.js index efcc7c45b14..4fcf5626fcf 100644 --- a/js/src/forum/states/PostStreamState.js +++ b/js/src/forum/states/PostStreamState.js @@ -1,3 +1,4 @@ +import { throttle } from 'lodash-es'; import anchorScroll from '../../common/utils/anchorScroll'; class PostStreamState { @@ -50,6 +51,9 @@ class PostStreamState { */ this.forceUpdateScrubber = false; + this.loadNext = throttle(this._loadNext, 300); + this.loadPrevious = throttle(this._loadPrevious, 300); + this.show(includedPosts); } @@ -189,7 +193,7 @@ class PostStreamState { /** * Load the next page of posts. */ - loadNext() { + _loadNext() { const start = this.visibleEnd; const end = (this.visibleEnd = this.sanitizeIndex(this.visibleEnd + this.constructor.loadCount)); @@ -212,7 +216,7 @@ class PostStreamState { /** * Load the previous page of posts. */ - loadPrevious() { + _loadPrevious() { const end = this.visibleStart; const start = (this.visibleStart = this.sanitizeIndex(this.visibleStart - this.constructor.loadCount));