Ported disconnect to customer-side, although it doesn't and will problably never work due to the way browsers handle unload()
bzr revid: nicolas.vanhoren@openerp.com-20130204104346-j63yl3chc2gfxdzq
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user