From c9b547368b3a404d1f183dddc00e5d6c02a1be14 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 22 Jul 2017 13:10:57 +0100 Subject: [PATCH] add algo to ensure that RM always moves forwards this is needed so that if a client which does not hide any events sets and RM at bottom of timeline, then riot-web which hides events sets the RM it'd set it at X-N where X is bottom and N is the amount of hidden events at bottom of the timeline, this way now an RM will fall through to the hidden events below a seen event. Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/TimelinePanel.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/structures/TimelinePanel.js b/src/components/structures/TimelinePanel.js index 0aee19545c..b07b975b5e 100644 --- a/src/components/structures/TimelinePanel.js +++ b/src/components/structures/TimelinePanel.js @@ -1020,7 +1020,14 @@ var TimelinePanel = React.createClass({ var boundingRect = node.getBoundingClientRect(); if ((allowPartial && boundingRect.top < wrapperRect.bottom) || (!allowPartial && boundingRect.bottom < wrapperRect.bottom)) { - return i; + let latestReadEventIndex = i; + // Place the RM at a hidden event below the latest seen event (if exists) + // to prevent RM going up the timeline between clients which do not hide the same events. + for (let j = i; j < this.state.events.length; ++j) { + if (messagePanel._shouldShowEvent(this.state.events[j])) break; + latestReadEventIndex = j; + } + return latestReadEventIndex; } } return null;