Now can disconnect from a group chat
bzr revid: nicolas.vanhoren@openerp.com-20130904131753-bdp93e8vwtg4za7n
This commit is contained in:
parent
acea8a695b
commit
85e52d1f86
|
@ -232,6 +232,10 @@ class im_session(osv.osv):
|
|||
raise Exception("Not allowed to modify a session when you are not in it.")
|
||||
self.write(cr, uid, session_id, {"user_ids": [(4, user_id)]}, context=context)
|
||||
|
||||
def remove_me_from_session(self, cr, uid, session_id, uuid=None, context=None):
|
||||
my_id = self.pool.get("im.user").get_my_id(cr, uid, uuid, context=context)
|
||||
self.write(cr, openerp.SUPERUSER_ID, session_id, {"user_ids": [(3, my_id)]}, context=context)
|
||||
|
||||
class im_user(osv.osv):
|
||||
_name = "im.user"
|
||||
|
||||
|
|
|
@ -295,7 +295,7 @@ function declare($, _, openerp) {
|
|||
className: "openerp_style oe_im_chatview",
|
||||
events: {
|
||||
"keydown input": "keydown",
|
||||
"click .oe_im_chatview_close": "destroy",
|
||||
"click .oe_im_chatview_close": "close",
|
||||
"click .oe_im_chatview_header": "show_hide"
|
||||
},
|
||||
init: function(parent, c_manager, session_id, options) {
|
||||
|
@ -467,6 +467,20 @@ function declare($, _, openerp) {
|
|||
if (! this.shown)
|
||||
this.show_hide();
|
||||
},
|
||||
close: function() {
|
||||
var def = $.when();
|
||||
if (this.get("users").length > 1) {
|
||||
def = im_common.connection.model("im.session").call("remove_me_from_session",
|
||||
[this.session_id, this.c_manager.me.get("uuid")]).then(_.bind(function() {
|
||||
return this.send_message(JSON.stringify({"type": "session_modified", "action": "removed",
|
||||
"user_id": this.c_manager.me.get("id")}), true)
|
||||
}, this))
|
||||
}
|
||||
|
||||
return def.then(_.bind(function() {
|
||||
this.destroy();
|
||||
}, this));
|
||||
},
|
||||
destroy: function() {
|
||||
_.each(this.get("users"), function(user) {
|
||||
user.remove_watcher();
|
||||
|
|
Loading…
Reference in New Issue