Merge pull request #982 from turt2live/travis/presence-undefined

Fix rare case where presence duration is undefined
This commit is contained in:
Matthew Hodgson 2017-06-01 00:38:50 +01:00 committed by GitHub
commit cad2f643ea
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)); var d = parseInt(t / (60 * 60 * 24));
if (t < 60) { if (t < 60) {
if (t < 0) { 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) { if (t < 60 * 60) {
return m + "m"; return _t("for %(amount)sm", {amount: m});
} }
if (t < 24 * 60 * 60) { 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) { getPrettyPresence: function(presence) {
@ -77,9 +77,8 @@ module.exports = React.createClass({
render: function() { render: function() {
if (this.props.activeAgo >= 0) { if (this.props.activeAgo >= 0) {
var ago = this.props.currentlyActive ? "" : "for " + (this.getDuration(this.props.activeAgo)); let duration = this.getDuration(this.props.activeAgo);
// var ago = this.getDuration(this.props.activeAgo) + " ago"; let ago = this.props.currentlyActive || !duration ? "" : duration;
// if (this.props.currentlyActive) ago += " (now?)";
return ( return (
<div className="mx_PresenceLabel"> <div className="mx_PresenceLabel">
{ this.getPrettyPresence(this.props.presenceState) } { ago } { this.getPrettyPresence(this.props.presenceState) } { ago }

View File

@ -765,6 +765,10 @@
"Drop file here to upload": "Drop file here to upload", "Drop file here to upload": "Drop file here to upload",
" (unsupported)": " (unsupported)", " (unsupported)": " (unsupported)",
"Ongoing conference call%(supportedText)s. %(joinText)s": "Ongoing conference call%(supportedText)s. %(joinText)s", "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", "Online": "Online",
"Idle": "Idle", "Idle": "Idle",
"Offline": "Offline", "Offline": "Offline",