converse-core: Call _tearDown when initialized again

When it's clear that a previous teardown didn't happen.
So that objects can be garbage collected and that obsolete event handlers don't
fire anymore.
This commit is contained in:
JC Brand 2016-12-06 11:07:52 +00:00
parent bd81a98ffa
commit 008c07596a

View File

@ -134,6 +134,15 @@
settings = typeof settings !== "undefined" ? settings : {};
var init_deferred = new $.Deferred();
var converse = this;
if (typeof converse.chatboxes !== 'undefined') {
// Looks like converse.initialized was called again without logging
// out or disconnecting in the previous session.
// This happens in tests.
// We therefore first clean up.
converse._tearDown();
}
var unloadevent;
if ('onpagehide' in window) {
// Pagehide gets thrown in more cases than unload. Specifically it