Browse Source

Merge branch 'master' into mockup

JC Brand 12 years ago
parent
commit
359dbc68f7
3 changed files with 30 additions and 15 deletions
  1. 7 0
      CHANGES.rst
  2. 1 1
      bower.json
  3. 22 14
      converse.js

+ 7 - 0
CHANGES.rst

@@ -1,6 +1,13 @@
 Changelog
 =========
 
+0.5.3 (Unreleased)
+------------------
+
+- Register presence and message handlers before fetching the roster. Otherwise
+  some presence notifications might be missed. [jcbrand]
+- Add a debug option (logs to the browser console). [jcbrand]
+
 0.5.2 (2013-08-05)
 ------------------
 

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "converse",
-  "version": "0.5.0",
+  "version": "0.5.2",
   "devDependencies": {
     "jasmine": "https://github.com/jcbrand/jasmine.git#1_3_x"
   },

+ 22 - 14
converse.js

@@ -48,6 +48,7 @@
         this.auto_list_rooms = false;
         this.auto_subscribe = false;
         this.bosh_service_url = ''; // The BOSH connection manager URL. Required if you are not prebinding.
+        this.debug = false;
         this.hide_muc_server = false;
         this.i18n = locales.en;
         this.prebind = false;
@@ -2615,8 +2616,13 @@
 
         this.onConnected = function (connection, callback) {
             this.connection = connection;
-            this.connection.xmlInput = function (body) { console.log(body); };
-            this.connection.xmlOutput = function (body) { console.log(body); };
+            if (this.debug) {
+                this.connection.xmlInput = function (body) { console.log(body); };
+                this.connection.xmlOutput = function (body) { console.log(body); };
+                Strophe.log = function (level, msg) {
+                    console.log(level+' '+msg);
+                };
+            }
             this.bare_jid = Strophe.getBareJidFromJid(this.connection.jid);
             this.domain = Strophe.getDomainFromJid(this.connection.jid);
             this.features = new this.Features();
@@ -2627,18 +2633,20 @@
                     $.proxy(this.roster.subscribeToSuggestedItems, this.roster),
                     'http://jabber.org/protocol/rosterx', 'message', null);
 
-                this.connection.roster.get($.proxy(function (a) {
-                    this.connection.addHandler(
-                            $.proxy(function (presence) {
-                                this.presenceHandler(presence);
-                                return true;
-                            }, this.roster), null, 'presence', null);
-                    this.connection.addHandler(
-                            $.proxy(function (message) {
-                                this.chatboxes.messageReceived(message);
-                                return true;
-                            }, this), null, 'message', 'chat');
-                }, this));
+                this.connection.addHandler(
+                        $.proxy(function (presence) {
+                            this.presenceHandler(presence);
+                            return true;
+                        }, this.roster), null, 'presence', null);
+
+                this.connection.addHandler(
+                        $.proxy(function (message) {
+                            this.chatboxes.messageReceived(message);
+                            return true;
+                        }, this), null, 'message', 'chat');
+
+                this.connection.roster.get(function () {});
+
                 $(window).on("blur focus", $.proxy(function(e) {
                     if ((this.windowState != e.type) && (e.type == 'focus')) {
                         converse.clearMsgCounter();