From 7398d414058cbd674ecd00634d1148f05255adee Mon Sep 17 00:00:00 2001 From: JC Brand Date: Tue, 31 May 2016 09:39:14 +0000 Subject: [PATCH] Some improvements to constructPresence Don't 'offline'. Only include status_message when explicitly passed in as a string. --- src/converse-core.js | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/converse-core.js b/src/converse-core.js index 1a48001e5..28f802157 100755 --- a/src/converse-core.js +++ b/src/converse-core.js @@ -1431,15 +1431,11 @@ }, constructPresence: function (type, status_message) { - if (typeof type !== 'string') { - type = this.get('status') || converse.default_state; - } - if (typeof status_message !== 'string') { - status_message = this.get('status_message'); - } var presence; + type = typeof type === 'string' ? type : (this.get('status') || converse.default_state); + status_message = typeof status_message === 'string' ? status_message : undefined; // Most of these presence types are actually not explicitly sent, - // but I add all of them here fore reference and future proofing. + // but I add all of them here for reference and future proofing. if ((type === 'unavailable') || (type === 'probe') || (type === 'error') || @@ -1450,18 +1446,13 @@ presence = $pres({'type': type}); } else if (type === 'offline') { presence = $pres({'type': 'unavailable'}); - if (status_message) { - presence.c('show').t(type); - } + } else if (type === 'online') { + presence = $pres(); } else { - if (type === 'online') { - presence = $pres(); - } else { - presence = $pres().c('show').t(type).up(); - } - if (status_message) { - presence.c('status').t(status_message); - } + presence = $pres().c('show').t(type).up(); + } + if (status_message) { + presence.c('status').t(status_message); } return presence; },