Remove ill-concieved delay before sending read receipts & instead just wait a bit before removing the ghost read marker.

This commit is contained in:
David Baker 2016-01-12 17:48:34 +00:00
parent 4a8b5dfe3a
commit 848cb30ea4

View file

@ -103,12 +103,6 @@ module.exports = React.createClass({
}, },
componentWillUnmount: function() { componentWillUnmount: function() {
// if we're waiting to send a read receipt, don't:
// message wasn't on screen for long enough
if (this.sendRRTimer) {
clearTimeout(this.sendRRTimer);
}
if (this.refs.messagePanel) { if (this.refs.messagePanel) {
// disconnect the D&D event listeners from the message panel. This // disconnect the D&D event listeners from the message panel. This
// is really just for hygiene - the messagePanel is going to be // is really just for hygiene - the messagePanel is going to be
@ -770,7 +764,7 @@ module.exports = React.createClass({
if (readMarkerIndex === undefined && ghostIndex && ghostIndex <= ret.length) { if (readMarkerIndex === undefined && ghostIndex && ghostIndex <= ret.length) {
var hr; var hr;
hr = (<hr className="mx_RoomView_myReadMarker" style={{opacity: 1, width: '85%'}} ref={function(n) { hr = (<hr className="mx_RoomView_myReadMarker" style={{opacity: 1, width: '85%'}} ref={function(n) {
Velocity(n, {opacity: '0', width: '10%'}, {duration: 400, easing: 'easeInSine', complete: function() { Velocity(n, {opacity: '0', width: '10%'}, {duration: 400, easing: 'easeInSine', delay: 1000, complete: function() {
self.setState({readMarkerGhostEventId: undefined}); self.setState({readMarkerGhostEventId: undefined});
}}); }});
}} />); }} />);
@ -885,20 +879,15 @@ 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 currentReadUpToEventId = this.state.room.getEventReadUpTo(MatrixClientPeg.get().credentials.userId);
var self = this; var currentReadUpToEventIndex = this._indexForEventId(currentReadUpToEventId);
this.sendRRTimer = setTimeout(function() {
self.sendRRTimer = undefined;
var currentReadUpToEventId = self.state.room.getEventReadUpTo(MatrixClientPeg.get().credentials.userId);
var currentReadUpToEventIndex = self._indexForEventId(currentReadUpToEventId);
var lastReadEventIndex = self._getLastDisplayedEventIndexIgnoringOwn(); var lastReadEventIndex = this._getLastDisplayedEventIndexIgnoringOwn();
if (lastReadEventIndex === null) return; if (lastReadEventIndex === null) return;
if (lastReadEventIndex > currentReadUpToEventIndex) { if (lastReadEventIndex > currentReadUpToEventIndex) {
MatrixClientPeg.get().sendReadReceipt(self.state.room.timeline[lastReadEventIndex]); MatrixClientPeg.get().sendReadReceipt(this.state.room.timeline[lastReadEventIndex]);
} }
}, SEND_READ_RECEIPT_DELAY);
}, },
_getLastDisplayedEventIndexIgnoringOwn: function() { _getLastDisplayedEventIndexIgnoringOwn: function() {