Commit 86c20ce2 authored by JC Brand's avatar JC Brand

muc: When exiting, don't wait for confirmation before cleaning up

During logout we don't have enough time.
parent 53643ab5
...@@ -134,6 +134,14 @@ ...@@ -134,6 +134,14 @@
// //
// New functions which don't exist yet can also be added. // New functions which don't exist yet can also be added.
_tearDown: function () {
var rooms = this.chatboxes.where({'type': CHATROOMS_TYPE});
_.each(rooms, function (room) {
room.save({'connection_status': ROOMSTATUS.DISCONNECTED});
});
this.__super__._tearDown.call(this, arguments);
},
Features: { Features: {
addClientFeatures: function () { addClientFeatures: function () {
var _converse = this.__super__._converse; var _converse = this.__super__._converse;
...@@ -1226,14 +1234,16 @@ ...@@ -1226,14 +1234,16 @@
return this; return this;
}, },
cleanup: function () { sendUnavailablePresence: function (exit_msg) {
if (this.model.collection && this.model.collection.browserStorage) { var presence = $pres({
this.model.save('connection_status', ROOMSTATUS.DISCONNECTED); type: "unavailable",
} else { from: _converse.connection.jid,
this.model.set('connection_status', ROOMSTATUS.DISCONNECTED); to: this.getRoomJIDAndNick()
});
if (exit_msg !== null) {
presence.c("status", exit_msg);
} }
this.removeHandlers(); _converse.connection.sendPresence(presence);
_converse.ChatBoxView.prototype.close.apply(this, arguments);
}, },
leave: function(exit_msg) { leave: function(exit_msg) {
...@@ -1246,26 +1256,16 @@ ...@@ -1246,26 +1256,16 @@
this.hide(); this.hide();
this.occupantsview.model.reset(); this.occupantsview.model.reset();
this.occupantsview.model.browserStorage._clear(); this.occupantsview.model.browserStorage._clear();
if (!_converse.connection.connected || if (_converse.connection.connected) {
this.model.get('connection_status') === ROOMSTATUS.DISCONNECTED) { this.sendUnavailablePresence(exit_msg);
// Don't send out a stanza if we're not connected.
this.cleanup();
return;
} }
var presence = $pres({ if (utils.isPersistableModel(this.model)) {
type: "unavailable", this.model.save('connection_status', ROOMSTATUS.DISCONNECTED);
from: _converse.connection.jid, } else {
to: this.getRoomJIDAndNick() this.model.set('connection_status', ROOMSTATUS.DISCONNECTED);
});
if (exit_msg !== null) {
presence.c("status", exit_msg);
} }
_converse.connection.sendPresence( this.removeHandlers();
presence, _converse.ChatBoxView.prototype.close.apply(this, arguments);
this.cleanup.bind(this),
this.cleanup.bind(this),
2000
);
}, },
renderConfigurationForm: function (stanza) { renderConfigurationForm: function (stanza) {
......
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