From 88e6be9d0ee35eb8ccc1e394d521fcac1dae56d3 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Tue, 7 Jul 2020 21:46:34 -0400 Subject: [PATCH] When scrolling to first post, scroll all the way to top, simplify scrollToItem promise structure --- js/src/forum/components/PostStream.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/js/src/forum/components/PostStream.js b/js/src/forum/components/PostStream.js index 31cbce362..baf2dcea6 100644 --- a/js/src/forum/components/PostStream.js +++ b/js/src/forum/components/PostStream.js @@ -342,15 +342,15 @@ export default class PostStream extends Component { } } - return Promise.all([$container.promise(), this.state.loadPromise]) - .then(() => { - m.redraw(true); - return $(window).scrollTop($(`.PostStream-item[data-index=${$item.data('index')}]`).offset().top - this.getMarginTop()); - }) - .then(() => { - return this.calculatePosition(); - }) - .then(() => this.state.unpause()); + return Promise.all([$container.promise(), this.state.loadPromise]).then(() => { + const index = $item.data('index'); + this.updateScrubber(); + m.redraw(true); + const scroll = index == 0 ? 0 : $(`.PostStream-item[data-index=${$item.data('index')}]`).offset().top - this.getMarginTop(); + $(window).scrollTop(scroll); + this.calculatePosition(); + this.state.unpause(); + }); } /**