From 7f766d89c32feba745c3d3000c64e94be5431226 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 10 May 2017 14:42:06 +0100 Subject: [PATCH] Rename variables, more comments --- src/components/structures/TimelinePanel.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/components/structures/TimelinePanel.js b/src/components/structures/TimelinePanel.js index 973c619904..874c6b1ac0 100644 --- a/src/components/structures/TimelinePanel.js +++ b/src/components/structures/TimelinePanel.js @@ -507,7 +507,7 @@ var TimelinePanel = React.createClass({ // if no client or client is guest don't send RR or RM if (!cli || cli.isGuest()) return; - let shouldSendRR = true; + let shouldSendReadReceipt = true; var currentReadUpToEventId = this._getCurrentReadReceipt(true); var currentReadUpToEventIndex = this._indexForEventId(currentReadUpToEventId); @@ -526,26 +526,30 @@ var TimelinePanel = React.createClass({ // if (currentReadUpToEventId && currentReadUpToEventIndex === null && this._timelineWindow.canPaginate(EventTimeline.FORWARDS)) { - shouldSendRR = false; + shouldSendReadReceipt = false; } var lastReadEventIndex = this._getLastDisplayedEventIndex({ ignoreOwn: true }); if (lastReadEventIndex === null) { - shouldSendRR = false; + shouldSendReadReceipt = false; } var lastReadEvent = this.state.events[lastReadEventIndex]; - shouldSendRR = shouldSendRR && - (lastReadEventIndex > currentReadUpToEventIndex && - this.last_rr_sent_event_id != lastReadEvent.getId()); + shouldSendReadReceipt = shouldSendReadReceipt && + // Only send a RR if the last read Event is ahead in the timeline relative to + // the current RR event. + lastReadEventIndex > currentReadUpToEventIndex && + // Only send a RR if the last RR set != the one we would send + this.last_rr_sent_event_id != lastReadEvent.getId(); - const shouldSendRM = this.last_rm_sent_event_id != this.state.readMarkerEventId; + // Only send a RM if the last RM sent != the one we would send + const shouldSendReadMarker = this.last_rm_sent_event_id != this.state.readMarkerEventId; // we also remember the last read receipt we sent to avoid spamming the // same one at the server repeatedly - if (shouldSendRR || shouldSendRM) { + if (shouldSendReadReceipt || shouldSendReadMarker) { this.last_rr_sent_event_id = lastReadEvent.getId(); this.last_rm_sent_event_id = this.state.readMarkerEventId;