From 3373f00d90337e0ad83941c13dd70d49be3c1455 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 29 Mar 2017 14:08:31 +0100 Subject: [PATCH 1/2] Only clear the local notification count if needed Only zero the local notification count when we actually send a read receipt, otherwise we cause a re-render of the RoomList every time the user moves the cursor in the window, basically. --- src/components/structures/TimelinePanel.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/components/structures/TimelinePanel.js b/src/components/structures/TimelinePanel.js index 7fe515b958..ac4a7cbffc 100644 --- a/src/components/structures/TimelinePanel.js +++ b/src/components/structures/TimelinePanel.js @@ -473,16 +473,6 @@ var TimelinePanel = React.createClass({ // we still have a client. if (!MatrixClientPeg.get()) return; - // if we are scrolled to the bottom, do a quick-reset of our unreadNotificationCount - // to avoid having to wait from the remote echo from the homeserver. - if (this.isAtEndOfLiveTimeline()) { - this.props.timelineSet.room.setUnreadNotificationCount('total', 0); - this.props.timelineSet.room.setUnreadNotificationCount('highlight', 0); - dis.dispatch({ - action: 'on_room_read', - }); - } - var currentReadUpToEventId = this._getCurrentReadReceipt(true); var currentReadUpToEventIndex = this._indexForEventId(currentReadUpToEventId); @@ -520,6 +510,14 @@ var TimelinePanel = React.createClass({ // it failed, so allow retries next time the user is active this.last_rr_sent_event_id = undefined; }); + + // do a quick-reset of our unreadNotificationCount to avoid having + // to wait from the remote echo from the homeserver. + this.props.timelineSet.room.setUnreadNotificationCount('total', 0); + this.props.timelineSet.room.setUnreadNotificationCount('highlight', 0); + dis.dispatch({ + action: 'on_room_read', + }); } }, From 90242c2c851454a31ace58d7f0c077aaafba9539 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 29 Mar 2017 14:12:50 +0100 Subject: [PATCH 2/2] Only send local echo RR if we're at the end --- src/components/structures/TimelinePanel.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/structures/TimelinePanel.js b/src/components/structures/TimelinePanel.js index ac4a7cbffc..07e534a359 100644 --- a/src/components/structures/TimelinePanel.js +++ b/src/components/structures/TimelinePanel.js @@ -513,11 +513,16 @@ var TimelinePanel = React.createClass({ // do a quick-reset of our unreadNotificationCount to avoid having // to wait from the remote echo from the homeserver. - this.props.timelineSet.room.setUnreadNotificationCount('total', 0); - this.props.timelineSet.room.setUnreadNotificationCount('highlight', 0); - dis.dispatch({ - action: 'on_room_read', - }); + // we only do this if we're right at the end, because we're just assuming + // that sending an RR for the latest message will set our notif counter + // to zero: it may not do this if we send an RR for somewhere before the end. + if (this.isAtEndOfLiveTimeline()) { + this.props.timelineSet.room.setUnreadNotificationCount('total', 0); + this.props.timelineSet.room.setUnreadNotificationCount('highlight', 0); + dis.dispatch({ + action: 'on_room_read', + }); + } } },