From bd7553d1ea5a35462d72eb99f8d2a80a48439677 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 8 Dec 2016 16:23:20 +0000 Subject: [PATCH] Add read receipt times to the hovertip of read markers Fixes #2709. Surprisingly, this data was never passed down to ReadReceiptMarker. --- src/components/views/avatars/MemberAvatar.js | 3 ++- src/components/views/rooms/EventTile.js | 15 +++++++++++++++ src/components/views/rooms/ReadReceiptMarker.js | 10 ++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/components/views/avatars/MemberAvatar.js b/src/components/views/avatars/MemberAvatar.js index 1f6736138d..c8a9abb4fe 100644 --- a/src/components/views/avatars/MemberAvatar.js +++ b/src/components/views/avatars/MemberAvatar.js @@ -33,6 +33,7 @@ module.exports = React.createClass({ onClick: React.PropTypes.func, // Whether the onClick of the avatar should be overriden to dispatch 'view_user' viewUserOnClick: React.PropTypes.bool, + title: React.PropTypes.string, }, getDefaultProps: function() { @@ -58,7 +59,7 @@ module.exports = React.createClass({ } return { name: props.member.name, - title: props.member.userId, + title: props.title || props.member.userId, imageUrl: Avatar.avatarUrlForMember(props.member, props.width, props.height, diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js index 8dd84f9364..9da3f7b265 100644 --- a/src/components/views/rooms/EventTile.js +++ b/src/components/views/rooms/EventTile.js @@ -290,6 +290,18 @@ module.exports = WithMatrixClient(React.createClass({ var left = 0; + var readReceiptData = Object.create(null); + var room = this.props.matrixClient.getRoom(this.props.mxEvent.getRoomId()); + if (room) { + // [ {type/userId/data} ] + room.getReceiptsForEvent(this.props.mxEvent).forEach(function(r) { + if (r.type !== "m.read" || !r.data.ts) { + return; + } + readReceiptData[r.userId] = r.data; + }) + } + var receipts = this.props.readReceipts || []; for (var i = 0; i < receipts.length; ++i) { var member = receipts[i]; @@ -312,6 +324,8 @@ module.exports = WithMatrixClient(React.createClass({ //console.log("i = " + i + ", MAX_READ_AVATARS = " + MAX_READ_AVATARS + ", allReadAvatars = " + this.state.allReadAvatars + " visibility = " + style.visibility); + var rData = readReceiptData[member.userId]; + // add to the start so the most recent is on the end (ie. ends up rightmost) avatars.unshift( ); diff --git a/src/components/views/rooms/ReadReceiptMarker.js b/src/components/views/rooms/ReadReceiptMarker.js index 91ba201683..ddf271d6f4 100644 --- a/src/components/views/rooms/ReadReceiptMarker.js +++ b/src/components/views/rooms/ReadReceiptMarker.js @@ -60,6 +60,9 @@ module.exports = React.createClass({ // callback for clicks on this RR onClick: React.PropTypes.func, + + // Timestamp when the receipt was read + timestamp: React.PropTypes.number, }, getDefaultProps: function() { @@ -162,6 +165,12 @@ module.exports = React.createClass({ visibility: this.props.hidden ? 'hidden' : 'visible', }; + var title; + if (this.props.timestamp) { + // "7:05:45 PM (@alice:matrix.org)" + title = new Date(this.props.timestamp).toLocaleTimeString() + " (" + this.props.member.userId + ")"; + } + return (