diff --git a/converse.js b/converse.js index cdb10dc30..b2efdc771 100644 --- a/converse.js +++ b/converse.js @@ -3509,7 +3509,7 @@ idx = _.indexOf(resources, resource); if (idx !== -1) { resources.splice(idx, 1); - item.set({'resources': resources}); + item.save({'resources': resources}); return resources.length; } } @@ -3721,9 +3721,10 @@ this.unsubscribe(bare_jid); } else if (presence_type === 'unavailable') { if (this.removeResource(bare_jid, resource) === 0) { - if (contact) { - contact.save({'chat_status': 'offline'}); - } + chat_status = "offline"; + } + if (contact && chat_status) { + contact.save({'chat_status': chat_status}); } } else if (contact) { // presence_type is undefined @@ -4322,7 +4323,12 @@ (type === 'unsubscribed') || (type === 'subscribe') || (type === 'subscribed')) { - presence = $pres({'type':type}); + 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(); diff --git a/docs/CHANGES.rst b/docs/CHANGES.rst index 34954859e..cb88feac8 100644 --- a/docs/CHANGES.rst +++ b/docs/CHANGES.rst @@ -14,6 +14,7 @@ Changelog any prebind session tokens. [jcbrand] * #46 Refactor the API and add new methods. [jcbrand] * #151 Browser locks/freezes with many roster users. [jcbrand] +* #177 Setting status to offline does nothing. [jcbrand] * #232 Always get full name from model. [jcbrand] * #237 Unable to create room when ``hide_muc_server`` is ``true``. [jcbrand] * #238 Rooms are not shown when ``hide_offline_users`` is ``true``. [jcbrand]