Commit 28936575 authored by JC Brand's avatar JC Brand

Move code into removeRoom method for reuse

parent 631c252e
...@@ -117,6 +117,14 @@ ...@@ -117,6 +117,14 @@
return this._connection.send(msg); return this._connection.send(msg);
}, },
removeRoom: function (room) {
delete this.rooms[room];
if (this.rooms.length === 0) {
this._connection.deleteHandler(this._muc_handler);
this._muc_handler = null;
}
},
leave: function(room, nick, handler_cb, exit_msg) { leave: function(room, nick, handler_cb, exit_msg) {
/* Leave a multi-user chat room /* Leave a multi-user chat room
* *
...@@ -129,11 +137,7 @@ ...@@ -129,11 +137,7 @@
* iqid - The unique id for the room leave. * iqid - The unique id for the room leave.
*/ */
var presence, presenceid, room_nick; var presence, presenceid, room_nick;
delete this.rooms[room]; this.removeRoom(room);
if (this.rooms.length === 0) {
this._connection.deleteHandler(this._muc_handler);
this._muc_handler = null;
}
room_nick = this.test_append_nick(room, nick); room_nick = this.test_append_nick(room, nick);
presenceid = this._connection.getUniqueId(); presenceid = this._connection.getUniqueId();
presence = $pres({ presence = $pres({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment