diff --git a/addons/live_support/static/ext/static/js/livesupport.js b/addons/live_support/static/ext/static/js/livesupport.js index fef422ea97a..909aa498ebf 100644 --- a/addons/live_support/static/ext/static/js/livesupport.js +++ b/addons/live_support/static/ext/static/js/livesupport.js @@ -91,6 +91,7 @@ define(["nova", "jquery", "underscore", "oeclient", "require"], function(nova, $ this.activated = false; this.users_cache = {}; this.last = null; + this.unload_event_handler = _.bind(this.unload, this); }, start_polling: function() { var self = this; @@ -105,6 +106,7 @@ define(["nova", "jquery", "underscore", "oeclient", "require"], function(nova, $ connection.connector.call("/longpolling/im/activated", {}).then(function(activated) { if (activated) { self.activated = true; + $(window).on("unload", self.unload_event_handler); self.poll(); } }); @@ -112,6 +114,9 @@ define(["nova", "jquery", "underscore", "oeclient", "require"], function(nova, $ }); }); }, + unload: function() { + connection.getModel("im.user").call("im_disconnect", [], {uuid: this.me.get("uuid"), context: {}}); + }, ensure_users: function(user_ids) { var no_cache = {}; _.each(user_ids, function(el) { @@ -223,6 +228,7 @@ define(["nova", "jquery", "underscore", "oeclient", "require"], function(nova, $ }, this); }, destroy: function() { + $(window).off("unload", this.unload_event_handler); $(window).unbind("blur", this.blur_hdl); $(window).unbind("focus", this.focus_hdl); nova.DynamicProperties.destroy.call(this); diff --git a/addons/live_support/static/ext/test.html b/addons/live_support/static/ext/test.html index d464b95ef05..6a3124988e5 100644 --- a/addons/live_support/static/ext/test.html +++ b/addons/live_support/static/ext/test.html @@ -15,7 +15,7 @@ }, })(["livesupport", "jquery"], function(livesupport, jQuery) { jQuery.noConflict(); - livesupport.main("http://localhost:8069", "test", "admin", "a"); + livesupport.main("http://localhost", "test", "admin", "a"); }); diff --git a/addons/web_im/im.py b/addons/web_im/im.py index 6e4b221d012..93ccd89e2d8 100644 --- a/addons/web_im/im.py +++ b/addons/web_im/im.py @@ -264,6 +264,8 @@ class im_user(osv.osv): return self._im_change_status(cr, uid, True, uuid or uid, context) def im_disconnect(self, cr, uid, uuid=None, context=None): + import pudb + pudb.set_trace() return self._im_change_status(cr, uid, False, uuid or uid, context) def _im_change_status(self, cr, uid, new_one, uuid=None, context=None): diff --git a/addons/web_im/static/src/js/im.js b/addons/web_im/static/src/js/im.js index e64cbae587e..d39dbd98aaa 100644 --- a/addons/web_im/static/src/js/im.js +++ b/addons/web_im/static/src/js/im.js @@ -50,7 +50,6 @@ openerp.web_im = function(instance) { this.c_manager.set("right_offset", this.get("right_offset")); }, this)); this.user_search_dm = new instance.web.DropMisordered(); - this.unload_event_handler = _.bind(this.unload, this); }, start: function() { this.$el.css("right", -this.$el.outerWidth()); @@ -63,17 +62,8 @@ openerp.web_im = function(instance) { var self = this; - $(window).on("unload", this.unload_event_handler); - return this.c_manager.start_polling(); }, - unload: function() { - return new instance.web.Model("im.user").call("im_disconnect", [], {context: new instance.web.CompoundContext()}); - }, - destroy: function() { - $(window).off("unload", this.unload_event_handler); - this._super(); - }, calc_box: function() { var $topbar = instance.client.$(".oe_topbar"); var top = $topbar.offset().top + $topbar.height(); @@ -208,6 +198,7 @@ openerp.web_im = function(instance) { this.activated = false; this.users_cache = {}; this.last = null; + this.unload_event_handler = _.bind(this.unload, this); }, start_polling: function() { var self = this; @@ -220,12 +211,16 @@ openerp.web_im = function(instance) { self.rpc("/longpolling/im/activated", {}).then(function(activated) { if (activated) { self.activated = true; + $(window).on("unload", self.unload_event_handler); self.poll(); } }); }); }); }, + unload: function() { + return new instance.web.Model("im.user").call("im_disconnect", [], {context: new instance.web.CompoundContext()}); + }, ensure_users: function(user_ids) { var no_cache = {}; _.each(user_ids, function(el) { @@ -335,6 +330,7 @@ openerp.web_im = function(instance) { }, this); }, destroy: function() { + $(window).off("unload", this.unload_event_handler); $(window).unbind("blur", this.blur_hdl); $(window).unbind("focus", this.focus_hdl); this._super();