From 9c1a713c6e6f9afb6ce1e078a80ec1a124def540 Mon Sep 17 00:00:00 2001 From: Daniel Waterworth Date: Thu, 7 Nov 2019 09:46:00 +0000 Subject: [PATCH] FIX: The internal position on the topic timeline is a scroll position ... instead of a post index. This is so that updatePosition is called when switching between the last two scroll positions. --- .../discourse/widgets/topic-timeline.js.es6 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 index 36db3959ba2..a43e9fca544 100644 --- a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 +++ b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 @@ -187,8 +187,11 @@ createWidget("timeline-scrollarea", { } if (this.state.position !== result.scrollPosition) { - this.state.position = result.scrollPosition; - this.sendWidgetAction("updatePosition", current); + this.sendWidgetAction( + "updatePosition", + result.current, + result.scrollPosition + ); } return result; @@ -387,7 +390,7 @@ export default createWidget("topic-timeline", { return { position: null, excerpt: null }; }, - updatePosition(scrollPosition) { + updatePosition(postIdx, scrollPosition) { if (!this.attrs.fullScreen) { return; } @@ -403,7 +406,8 @@ export default createWidget("topic-timeline", { } // we have an off by one, stream is zero based, - stream.excerpt(scrollPosition - 1).then(info => { + // postIdx is 1 based + stream.excerpt(postIdx - 1).then(info => { if (info && this.state.position === scrollPosition) { let excerpt = "";