mirror of
https://github.com/element-hq/element-web
synced 2024-11-28 20:38:55 +03:00
Calculate what event we send a read receipt for after the delay so we send a receipt for the one the user actually settles on.
This commit is contained in:
parent
1c4d1d2507
commit
7b2d56f619
1 changed files with 11 additions and 18 deletions
|
@ -867,27 +867,20 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
sendReadReceipt: function() {
|
sendReadReceipt: function() {
|
||||||
if (!this.state.room) return;
|
if (!this.state.room) return;
|
||||||
|
if (this.sendRRTimer) clearTimeout(this.sendRRTimer);
|
||||||
|
var self = this;
|
||||||
|
this.sendRRTimer = setTimeout(function() {
|
||||||
|
self.sendRRTimer = undefined;
|
||||||
|
var currentReadUpToEventId = self.state.room.getEventReadUpTo(MatrixClientPeg.get().credentials.userId);
|
||||||
|
var currentReadUpToEventIndex = self._indexForEventId(currentReadUpToEventId);
|
||||||
|
|
||||||
var currentReadUpToEventId = this.state.room.getEventReadUpTo(MatrixClientPeg.get().credentials.userId);
|
var lastReadEventIndex = self._getLastDisplayedEventIndexIgnoringOwn();
|
||||||
var currentReadUpToEventIndex = this._indexForEventId(currentReadUpToEventId);
|
if (lastReadEventIndex === null) return;
|
||||||
|
|
||||||
var lastReadEventIndex = this._getLastDisplayedEventIndexIgnoringOwn();
|
if (lastReadEventIndex > currentReadUpToEventIndex) {
|
||||||
if (lastReadEventIndex === null) return;
|
MatrixClientPeg.get().sendReadReceipt(self.state.room.timeline[lastReadEventIndex]);
|
||||||
|
|
||||||
if (lastReadEventIndex > currentReadUpToEventIndex) {
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
var lastReadEventId = self.state.room.timeline[lastReadEventIndex].getId();
|
|
||||||
if (this.pendingRR != lastReadEventId) {
|
|
||||||
this.pendingRR = lastReadEventId;
|
|
||||||
if (this.sendRRTimer) clearTimeout(this.sendRRTimer);
|
|
||||||
this.sendRRTimer = setTimeout(function() {
|
|
||||||
MatrixClientPeg.get().sendReadReceipt(self.state.room.timeline[lastReadEventIndex]);
|
|
||||||
self.sendRRTimer = undefined;
|
|
||||||
self.pendingRR = undefined;
|
|
||||||
}, SEND_READ_RECEIPT_DELAY);
|
|
||||||
}
|
}
|
||||||
}
|
}, SEND_READ_RECEIPT_DELAY);
|
||||||
},
|
},
|
||||||
|
|
||||||
_getLastDisplayedEventIndexIgnoringOwn: function() {
|
_getLastDisplayedEventIndexIgnoringOwn: function() {
|
||||||
|
|
Loading…
Reference in a new issue