From 848cb30ea4cea8466ccc9e420db85894e5dae305 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 12 Jan 2016 17:48:34 +0000 Subject: [PATCH] Remove ill-concieved delay before sending read receipts & instead just wait a bit before removing the ghost read marker. --- src/components/structures/RoomView.js | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 04facc59fc..b06a4e23f4 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -103,12 +103,6 @@ module.exports = React.createClass({ }, 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) { // disconnect the D&D event listeners from the message panel. This // 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) { var hr; hr = (
); @@ -885,20 +879,15 @@ module.exports = React.createClass({ sendReadReceipt: function() { 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 currentReadUpToEventIndex = this._indexForEventId(currentReadUpToEventId); - var lastReadEventIndex = self._getLastDisplayedEventIndexIgnoringOwn(); - if (lastReadEventIndex === null) return; + var lastReadEventIndex = this._getLastDisplayedEventIndexIgnoringOwn(); + if (lastReadEventIndex === null) return; - if (lastReadEventIndex > currentReadUpToEventIndex) { - MatrixClientPeg.get().sendReadReceipt(self.state.room.timeline[lastReadEventIndex]); - } - }, SEND_READ_RECEIPT_DELAY); + if (lastReadEventIndex > currentReadUpToEventIndex) { + MatrixClientPeg.get().sendReadReceipt(this.state.room.timeline[lastReadEventIndex]); + } }, _getLastDisplayedEventIndexIgnoringOwn: function() {