From 6b32975e0c1ddf152053f1842642adf089406422 Mon Sep 17 00:00:00 2001 From: Kieran Gould Date: Fri, 19 May 2017 22:26:24 +0100 Subject: [PATCH] Add 12 hour class to mx_EventTile --- src/DateUtils.js | 7 ++---- src/components/views/rooms/EventTile.js | 32 ++++++++++--------------- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/DateUtils.js b/src/DateUtils.js index 1f231088a1..d516cf07bf 100644 --- a/src/DateUtils.js +++ b/src/DateUtils.js @@ -25,10 +25,9 @@ function pad(n) { function twelveHourTime(date) { let hours = date.getHours() % 12; - let minutes = pad(date.getMinutes()); + const minutes = pad(date.getMinutes()); const ampm = hours >= 12 ? 'PM' : 'AM'; hours = pad(hours ? hours : 12); - minutes = pad(minutes); return `${hours}:${minutes} ${ampm}`; } @@ -44,9 +43,7 @@ module.exports = { else if (now.getFullYear() === date.getFullYear()) { return days[date.getDay()] + ", " + months[date.getMonth()] + " " + date.getDate() + " " + this.formatTime(date); } - else { - return this.formatFullDate(date); - } + return this.formatFullDate(date); }, formatFullDate: function(date) { diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js index 6ec076ba95..fd5fa81390 100644 --- a/src/components/views/rooms/EventTile.js +++ b/src/components/views/rooms/EventTile.js @@ -406,9 +406,12 @@ module.exports = WithMatrixClient(React.createClass({ var isSending = (['sending', 'queued', 'encrypting'].indexOf(this.props.eventSendStatus) !== -1); const isRedacted = (eventType === 'm.room.message') && this.props.isRedacted; - var classes = classNames({ + const isTwelveHour = UserSettingsStore.getSyncedSetting('showTwelveHourTimestamps'); + + const classes = classNames({ mx_EventTile: true, mx_EventTile_info: isInfoMessage, + mx_EventTile_12hr: isTwelveHour, mx_EventTile_encrypting: this.props.eventSendStatus == 'encrypting', mx_EventTile_sending: isSending, mx_EventTile_notSent: this.props.eventSendStatus == 'not_sent', @@ -476,43 +479,34 @@ module.exports = WithMatrixClient(React.createClass({ } } - var editButton = ( + const editButton = ( ); - - var e2e; - let e2e_style; + let e2e; // cosmetic padlocks: - if (UserSettingsStore.getSyncedSetting('showTwelveHourTimestamps')) { - e2e_style = "mx_EventTile_e2eIcon mx_EventTile_e2eIcon_12hr"; - } - else { - e2e_style = "mx_EventTile_e2eIcon"; - } if ((e2eEnabled && this.props.eventSendStatus) || this.props.mxEvent.getType() === 'm.room.encryption') { - e2e = Encrypted by verified device; + e2e = Encrypted by verified device; } // real padlocks else if (this.props.mxEvent.isEncrypted() || (e2eEnabled && this.props.eventSendStatus)) { if (this.props.mxEvent.getContent().msgtype === 'm.bad.encrypted') { - e2e = Undecryptable; + e2e = Undecryptable; } else if (this.state.verified == true || (e2eEnabled && this.props.eventSendStatus)) { - e2e = Encrypted by verified device; + e2e = Encrypted by verified device; } else { - e2e = Encrypted by unverified device; + e2e = Encrypted by unverified device; } } else if (e2eEnabled) { - e2e = Unencrypted message; + e2e = Unencrypted message; } const timestamp = this.props.mxEvent.getTs() ? - : null; + : null; if (this.props.tileShape === "notif") { - var room = this.props.matrixClient.getRoom(this.props.mxEvent.getRoomId()); - + const room = this.props.matrixClient.getRoom(this.props.mxEvent.getRoomId()); return (