From 8f7359fce1060fb6c63b11e3ef89fa50abfcfaf1 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 27 Apr 2017 14:03:54 +0100 Subject: [PATCH 1/2] Only show jumpToReadMarker bar when RM !== RR If RM !== RR, use the pos. of the RM to determine whether it is visible, as before. --- src/components/structures/RoomView.js | 8 +------- src/components/structures/TimelinePanel.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 8a355a8f6d..a0c36374b6 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -1276,13 +1276,7 @@ module.exports = React.createClass({ return; } - var pos = this.refs.messagePanel.getReadMarkerPosition(); - - // we want to show the bar if the read-marker is off the top of the - // screen. - // If pos is null, the event might not be paginated, so show the unread bar! - var showBar = pos < 0 || pos === null; - + const showBar = this.refs.messagePanel.canJumpToReadMarker(); if (this.state.showTopUnreadMessagesBar != showBar) { this.setState({showTopUnreadMessagesBar: showBar}, this.onChildResize); diff --git a/src/components/structures/TimelinePanel.js b/src/components/structures/TimelinePanel.js index f07bad0052..066ab37107 100644 --- a/src/components/structures/TimelinePanel.js +++ b/src/components/structures/TimelinePanel.js @@ -766,6 +766,16 @@ var TimelinePanel = React.createClass({ return null; }, + canJumpToReadMarker: function() { + // Only show jump bar if RR !== RM. If they are the same, there are only fully + // read messages and unread messages. We already have a badge count and the bottom + // bar to jump to "live" when we have unread messages. + // We want to show the bar if the read-marker is off the top of the screen. + // Also, if pos === null, the event might not be paginated - show the unread bar + const pos = this.getReadMarkerPosition(); + return this.state.readMarkerEventId !== this._getCurrentReadReceipt() && (pos < 0 || pos === null); + }, + /** * called by the parent component when PageUp/Down/etc is pressed. * From 6313193aa80ae2dd311d13dfc85b9808b953a434 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 27 Apr 2017 16:52:40 +0100 Subject: [PATCH 2/2] Null check readMarkerEventId, update comment --- src/components/structures/TimelinePanel.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/structures/TimelinePanel.js b/src/components/structures/TimelinePanel.js index 066ab37107..f72d35c41c 100644 --- a/src/components/structures/TimelinePanel.js +++ b/src/components/structures/TimelinePanel.js @@ -767,13 +767,16 @@ var TimelinePanel = React.createClass({ }, canJumpToReadMarker: function() { - // Only show jump bar if RR !== RM. If they are the same, there are only fully + // 1. Do not show jump bar if neither the RM nor the RR are set. + // 2. Only show jump bar if RR !== RM. If they are the same, there are only fully // read messages and unread messages. We already have a badge count and the bottom // bar to jump to "live" when we have unread messages. - // We want to show the bar if the read-marker is off the top of the screen. - // Also, if pos === null, the event might not be paginated - show the unread bar + // 3. We want to show the bar if the read-marker is off the top of the screen. + // 4. Also, if pos === null, the event might not be paginated - show the unread bar const pos = this.getReadMarkerPosition(); - return this.state.readMarkerEventId !== this._getCurrentReadReceipt() && (pos < 0 || pos === null); + return this.state.readMarkerEventId !== null && // 1. + this.state.readMarkerEventId !== this._getCurrentReadReceipt() && // 2. + (pos < 0 || pos === null); // 3., 4. }, /**