Fix rare case where presence duration is undefined & i18n

pull/21833/head
turt2live 2017-05-31 11:55:25 -06:00
parent 92143f2dc2
commit 165dfeccb9
2 changed files with 11 additions and 8 deletions

View File

@ -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 (
<div className="mx_PresenceLabel">
{ this.getPrettyPresence(this.props.presenceState) } { ago }

View File

@ -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",