Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 165dfec

Browse files
committed
Fix rare case where presence duration is undefined & i18n
1 parent 92143f2 commit 165dfec

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/components/views/rooms/PresenceLabel.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ module.exports = React.createClass({
5555
var d = parseInt(t / (60 * 60 * 24));
5656
if (t < 60) {
5757
if (t < 0) {
58-
return "0s";
58+
return _t("for %(amount)ss", {amount: 0});
5959
}
60-
return s + "s";
60+
return _t("for %(amount)ss", {amount: s});
6161
}
6262
if (t < 60 * 60) {
63-
return m + "m";
63+
return _t("for %(amount)sm", {amount: m});
6464
}
6565
if (t < 24 * 60 * 60) {
66-
return h + "h";
66+
return _t("for %(amount)sh", {amount: h});
6767
}
68-
return d + "d ";
68+
return _t("for %(amount)sd", {amount: d});
6969
},
7070

7171
getPrettyPresence: function(presence) {
@@ -77,9 +77,8 @@ module.exports = React.createClass({
7777

7878
render: function() {
7979
if (this.props.activeAgo >= 0) {
80-
var ago = this.props.currentlyActive ? "" : "for " + (this.getDuration(this.props.activeAgo));
81-
// var ago = this.getDuration(this.props.activeAgo) + " ago";
82-
// if (this.props.currentlyActive) ago += " (now?)";
80+
let duration = this.getDuration(this.props.activeAgo);
81+
let ago = this.props.currentlyActive || !duration ? "" : duration;
8382
return (
8483
<div className="mx_PresenceLabel">
8584
{ this.getPrettyPresence(this.props.presenceState) } { ago }

src/i18n/strings/en_EN.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,10 @@
765765
"Drop file here to upload": "Drop file here to upload",
766766
" (unsupported)": " (unsupported)",
767767
"Ongoing conference call%(supportedText)s. %(joinText)s": "Ongoing conference call%(supportedText)s. %(joinText)s",
768+
"for %(amount)ss": "for %(amount)ss",
769+
"for %(amount)sm": "for %(amount)sm",
770+
"for %(amount)sh": "for %(amount)sh",
771+
"for %(amount)sd": "for %(amount)sd",
768772
"Online": "Online",
769773
"Idle": "Idle",
770774
"Offline": "Offline",

0 commit comments

Comments
 (0)