Rename variables, more comments

This commit is contained in:
Luke Barnard 2017-05-10 14:42:06 +01:00
parent ca79d9bb6e
commit 7f766d89c3

View File

@ -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;