diff --git a/CHANGES.rst b/CHANGES.rst index 763d30a7d..f32fa27a9 100644 --- a/CHANGES.rst +++ b/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) ------------------ diff --git a/bower.json b/bower.json index 04b0ed6b9..46012323c 100644 --- a/bower.json +++ b/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" }, diff --git a/converse.js b/converse.js index 3a55baee4..a6e192542 100644 --- a/converse.js +++ b/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();