improve comments

pull/21833/head
Bruno Windels 2019-07-15 14:01:28 +02:00 committed by David Baker
parent e66ebec083
commit d39a86b126
1 changed files with 8 additions and 9 deletions

View File

@ -1153,11 +1153,11 @@ const TimelinePanel = React.createClass({
}; };
// if allowEventsWithoutTiles is enabled, we keep track // if allowEventsWithoutTiles is enabled, we keep track
// of how many of the adjacent events were invisible (because no tile) // of how many of the adjacent events didn't have a tile
// but should have the read receipt moved past, so // but should have the read receipt moved past them, so
// we can include those once we find the last displayed (visible) event. // we can include those once we find the last displayed (visible) event.
// The counter is cleared when we ignore an event we don't want // The counter is not started for events we don't want
// to send a read receipt for (our own events, local echos) // to send a read receipt for (our own events, local echos).
let adjacentInvisibleEventCount = 0; let adjacentInvisibleEventCount = 0;
// Use `liveEvents` here because we don't want the read marker or read // Use `liveEvents` here because we don't want the read marker or read
// receipt to advance into pending events. // receipt to advance into pending events.
@ -1167,15 +1167,14 @@ const TimelinePanel = React.createClass({
const node = messagePanel.getNodeForEventId(ev.getId()); const node = messagePanel.getNodeForEventId(ev.getId());
const isInView = isNodeInView(node); const isInView = isNodeInView(node);
// the event at i + adjacentInvisibleEventCount should // when we've reached the first visible event, and the previous
// not be ignored, and it considered the first in view (at the bottom) // events were all invisible (with the first one not being ignored),
// because i is the first one in view and the adjacent ones are invisible, // return the index of the first invisible event.
// so return this without further ado.
if (isInView && adjacentInvisibleEventCount !== 0) { if (isInView && adjacentInvisibleEventCount !== 0) {
return i + adjacentInvisibleEventCount; return i + adjacentInvisibleEventCount;
} else { } else {
if (node && !isInView) { if (node && !isInView) {
// has node but not in view, so adjacent invisible events don't count // has node but not in view, so reset adjacent invisible events
adjacentInvisibleEventCount = 0; adjacentInvisibleEventCount = 0;
} }