Commit fe03940f authored by Guillermo Bonvehí's avatar Guillermo Bonvehí

Fix issue #305, show=online presence sent

setStatusMessage was modified to send the presence using
sendPresence method which skips show tag when type is 'online'
Added getStatus helper method
parent 65b1898f
...@@ -4250,7 +4250,7 @@ ...@@ -4250,7 +4250,7 @@
this.XMPPStatus = Backbone.Model.extend({ this.XMPPStatus = Backbone.Model.extend({
initialize: function () { initialize: function () {
this.set({ this.set({
'status' : this.get('status') || 'online' 'status' : this.getStatus()
}); });
this.on('change', $.proxy(function (item) { this.on('change', $.proxy(function (item) {
if (this.get('fullname') === undefined) { if (this.get('fullname') === undefined) {
...@@ -4270,12 +4270,14 @@ ...@@ -4270,12 +4270,14 @@
}, this)); }, this));
}, },
sendPresence: function (type) { sendPresence: function (type, status_message) {
if (type === undefined) { if (typeof type === 'undefined') {
type = this.get('status') || 'online'; type = this.get('status') || 'online';
} }
var status_message = this.get('status_message'), if (typeof status_message === 'undefined') {
presence; status_message = this.get('status_message');
}
var presence;
// Most of these presence types are actually not explicitly sent, // 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 fore reference and future proofing.
if ((type === 'unavailable') || if ((type === 'unavailable') ||
...@@ -4309,8 +4311,12 @@ ...@@ -4309,8 +4311,12 @@
this.save({'status': value}); this.save({'status': value});
}, },
getStatus: function() {
return this.get('status') || 'online';
},
setStatusMessage: function (status_message) { setStatusMessage: function (status_message) {
converse.connection.send($pres().c('show').t(this.get('status')).up().c('status').t(status_message)); this.sendPresence(this.getStatus(), status_message);
this.save({'status_message': status_message}); this.save({'status_message': status_message});
if (this.xhr_custom_status) { if (this.xhr_custom_status) {
$.ajax({ $.ajax({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment