-
-
Notifications
You must be signed in to change notification settings - Fork 832
Fix RM not updating if RR event unpaginated #874
Conversation
If the RR event has been unpaginated, the logic in `sendReadReceipt` will now fallback on the event ID of the RM which in theory is always =< RR event ID stream-wise.
@@ -575,7 +575,7 @@ module.exports = React.createClass({ | |||
var boundingRect = node.getBoundingClientRect(); | |||
var scrollDelta = boundingRect.bottom + pixelOffset - wrapperRect.bottom; | |||
|
|||
debuglog("ScrollPanel: scrolling to token '" + scrollToken + "'+" + | |||
console.log("ScrollPanel: scrolling to token '" + scrollToken + "'+" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👎
@@ -523,6 +525,7 @@ var TimelinePanel = React.createClass({ | |||
// RRs) - but that is a bit of a niche case. It will sort itself out when | |||
// the user eventually hits the live timeline. | |||
// | |||
console.log(currentReadUpToEventId, currentReadUpToEventIndex, this._timelineWindow.canPaginate(EventTimeline.FORWARDS)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops
@@ -544,6 +547,11 @@ var TimelinePanel = React.createClass({ | |||
this.last_rr_sent_event_id = lastReadEvent.getId(); | |||
this.last_rm_sent_event_id = this.state.readMarkerEventId; | |||
|
|||
console.log('TimelinePanel: Sending Read Markers for ', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unconvinced this is the right thing to do. In particular there is a comment saying that we don't want to send out RRs if we don't know what we're doing. Why can't you just leave the RR alone rather than sending an old one?
@@ -510,8 +510,10 @@ var TimelinePanel = React.createClass({ | |||
var currentReadUpToEventId = this._getCurrentReadReceipt(true); | |||
var currentReadUpToEventIndex = this._indexForEventId(currentReadUpToEventId); | |||
|
|||
currentReadUpToEventIndex = currentReadUpToEventIndex || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs a comment to explain what we're doing.
Isn't zero a valid index? why do we fall back in that case?
This is a fair point. I'll rewrite this to be a bit more stable and to accommodate RMs more sensibly. Any suggestions as to how to log things that I'd like to include in the logs are welcome. |
If you really want to include them in the rageshakes, then console.log it is. But do we really need to be this verbose? Could you use |
That's largely what I have been doing but this is subtle enough to be very difficult to reproduce when someone sends a rageshake about one particular instance of the RM not updating. TBH if I rewrite |
Instead of modifying the condition for updating the RR, separate the RM and RR conditions and use an OR to decide when to set both. Make some logs only log when DEBUG.
if (!cli || cli.isGuest()) return; | ||
|
||
let shouldSendRR = true; | ||
|
||
var currentReadUpToEventId = this._getCurrentReadReceipt(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it might be worth renaming these as 'read receipt' for consistency with the rest of the function - I'm finding it horribly confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
|
||
var lastReadEvent = this.state.events[lastReadEventIndex]; | ||
shouldSendRR = shouldSendRR && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could do with a comment: "only send a RR if ..."
this.last_rr_sent_event_id != lastReadEvent.getId()) || | ||
this.last_rm_sent_event_id != this.state.readMarkerEventId) { | ||
|
||
if (shouldSendRR || shouldSendRM) { | ||
this.last_rr_sent_event_id = lastReadEvent.getId(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it's possible for lastReadEvent to be undefined here (eg if lastReadEventIndex was null), which would make this blow up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now protected by shouldSendReadReceipt
which is set to false
if the index is null.
this.last_rr_sent_event_id != lastReadEvent.getId()) || | ||
this.last_rm_sent_event_id != this.state.readMarkerEventId) { | ||
|
||
if (shouldSendRR || shouldSendRM) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
surely if we've decided not to send a RR, then we, uh, shouldn't send a RR even if shouldSendRM
is true?
(in other words: pass null in the call to setRoomReadMarkers
and don't update last_rr_sent_event_id
)
@@ -177,8 +177,8 @@ var TimelinePanel = React.createClass({ | |||
componentWillMount: function() { | |||
debuglog("TimelinePanel: mounting"); | |||
|
|||
this.last_rr_sent_event_id = undefined; | |||
this.last_rm_sent_event_id = undefined; | |||
this.lastRRSentSentId = undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Sent/Event
(and throughout)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops!
|
||
const currentReadUpToEventId = this._getCurrentReadReceipt(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought you were going to rename these :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh right, I understood something else and agree they should be consistent
`ReadUpTo` -> `RR` `ReadReceipt` -> `RR` `ReadMarker` -> `RM`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm I think
If the RR event has been unpaginated, the logic in
sendReadReceipt
will now fallback on the event ID of the RM which in theory is always =< RR event ID stream-wise.Also add some logging to debug RM bugs.