From 486301cffb55aee0a7cfb3df1df3ff5a8ad3c228 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Mon, 15 May 2017 02:55:07 +0100 Subject: [PATCH] remove dodgy heuristics for hiding dates on RRs and use DateUtils instead. reverts https://github.com/matrix-org/matrix-react-sdk/pull/586/commits/5d99d68a64ec0c81b42c5a8e6959376dab798feb fixes https://github.com/vector-im/riot-web/issues/3523 --- src/components/views/rooms/EventTile.js | 11 ----------- src/components/views/rooms/ReadReceiptMarker.js | 17 ++++------------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js index e2e203f680..44c4051995 100644 --- a/src/components/views/rooms/EventTile.js +++ b/src/components/views/rooms/EventTile.js @@ -295,16 +295,6 @@ module.exports = WithMatrixClient(React.createClass({ const receiptOffset = 15; let left = 0; - // It's possible that the receipt was sent several days AFTER the event. - // If it is, we want to display the complete date along with the HH:MM:SS, - // rather than just HH:MM:SS. - let dayAfterEvent = new Date(this.props.mxEvent.getTs()); - dayAfterEvent.setDate(dayAfterEvent.getDate() + 1); - dayAfterEvent.setHours(0); - dayAfterEvent.setMinutes(0); - dayAfterEvent.setSeconds(0); - let dayAfterEventTime = dayAfterEvent.getTime(); - var receipts = this.props.readReceipts || []; for (var i = 0; i < receipts.length; ++i) { var receipt = receipts[i]; @@ -340,7 +330,6 @@ module.exports = WithMatrixClient(React.createClass({ suppressAnimation={this._suppressReadReceiptAnimation} onClick={this.toggleAllReadAvatars} timestamp={receipt.ts} - showFullTimestamp={receipt.ts >= dayAfterEventTime} /> ); } diff --git a/src/components/views/rooms/ReadReceiptMarker.js b/src/components/views/rooms/ReadReceiptMarker.js index 230efbd1ea..0911d50c3e 100644 --- a/src/components/views/rooms/ReadReceiptMarker.js +++ b/src/components/views/rooms/ReadReceiptMarker.js @@ -24,6 +24,8 @@ var sdk = require('../../../index'); var Velociraptor = require('../../../Velociraptor'); require('../../../VelocityBounce'); +import DateUtils from '../../../DateUtils'; + var bounce = false; try { if (global.localStorage) { @@ -63,9 +65,6 @@ module.exports = React.createClass({ // Timestamp when the receipt was read timestamp: React.PropTypes.number, - - // True to show the full date/time rather than just the time - showFullTimestamp: React.PropTypes.bool, }, getDefaultProps: function() { @@ -170,16 +169,8 @@ module.exports = React.createClass({ let title; if (this.props.timestamp) { - const prefix = "Seen by " + this.props.member.userId + " at "; - let ts = new Date(this.props.timestamp); - if (this.props.showFullTimestamp) { - // "15/12/2016, 7:05:45 PM (@alice:matrix.org)" - title = prefix + ts.toLocaleString(); - } - else { - // "7:05:45 PM (@alice:matrix.org)" - title = prefix + ts.toLocaleTimeString(); - } + title = "Seen by " + this.props.member.userId + " at " + + DateUtils.formatDate(new Date(this.props.timestamp)); } return (