Commit 008c0759 authored by JC Brand's avatar JC Brand

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.
parent bd81a98f
...@@ -134,6 +134,15 @@ ...@@ -134,6 +134,15 @@
settings = typeof settings !== "undefined" ? settings : {}; settings = typeof settings !== "undefined" ? settings : {};
var init_deferred = new $.Deferred(); var init_deferred = new $.Deferred();
var converse = this; 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; var unloadevent;
if ('onpagehide' in window) { if ('onpagehide' in window) {
// Pagehide gets thrown in more cases than unload. Specifically it // Pagehide gets thrown in more cases than unload. Specifically it
......
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