From 165dfeccb9a6a2ee7743cccd9676430b507d4aed Mon Sep 17 00:00:00 2001 From: turt2live Date: Wed, 31 May 2017 11:55:25 -0600 Subject: [PATCH] Fix rare case where presence duration is undefined & i18n --- src/components/views/rooms/PresenceLabel.js | 15 +++++++-------- src/i18n/strings/en_EN.json | 4 ++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/components/views/rooms/PresenceLabel.js b/src/components/views/rooms/PresenceLabel.js index d06b46641c..b79de2b21c 100644 --- a/src/components/views/rooms/PresenceLabel.js +++ b/src/components/views/rooms/PresenceLabel.js @@ -55,17 +55,17 @@ module.exports = React.createClass({ var d = parseInt(t / (60 * 60 * 24)); if (t < 60) { if (t < 0) { - return "0s"; + return _t("for %(amount)ss", {amount: 0}); } - return s + "s"; + return _t("for %(amount)ss", {amount: s}); } if (t < 60 * 60) { - return m + "m"; + return _t("for %(amount)sm", {amount: m}); } if (t < 24 * 60 * 60) { - return h + "h"; + return _t("for %(amount)sh", {amount: h}); } - return d + "d "; + return _t("for %(amount)sd", {amount: d}); }, getPrettyPresence: function(presence) { @@ -77,9 +77,8 @@ module.exports = React.createClass({ render: function() { if (this.props.activeAgo >= 0) { - var ago = this.props.currentlyActive ? "" : "for " + (this.getDuration(this.props.activeAgo)); - // var ago = this.getDuration(this.props.activeAgo) + " ago"; - // if (this.props.currentlyActive) ago += " (now?)"; + let duration = this.getDuration(this.props.activeAgo); + let ago = this.props.currentlyActive || !duration ? "" : duration; return (
{ this.getPrettyPresence(this.props.presenceState) } { ago } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index bd8b6d2367..729208dddc 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -765,6 +765,10 @@ "Drop file here to upload": "Drop file here to upload", " (unsupported)": " (unsupported)", "Ongoing conference call%(supportedText)s. %(joinText)s": "Ongoing conference call%(supportedText)s. %(joinText)s", + "for %(amount)ss": "for %(amount)ss", + "for %(amount)sm": "for %(amount)sm", + "for %(amount)sh": "for %(amount)sh", + "for %(amount)sd": "for %(amount)sd", "Online": "Online", "Idle": "Idle", "Offline": "Offline",