Pārlūkot izejas kodu

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
Guillermo Bonvehí 10 gadi atpakaļ
vecāks
revīzija
fe03940f53
1 mainītis faili ar 12 papildinājumiem un 6 dzēšanām
  1. 12 6
      converse.js

+ 12 - 6
converse.js

@@ -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 @@
                 }, this));
                 }, this));
             },
             },
 
 
-            sendPresence: function (type) {
-                if (type === undefined) {
+            sendPresence: function (type, status_message) {
+                if (typeof type === 'undefined') {
                     type = this.get('status') || 'online';
                     type = this.get('status') || 'online';
                 }
                 }
-                var status_message = this.get('status_message'),
-                    presence;
+                if (typeof status_message === 'undefined') {
+                    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 @@
                 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({