Add unregisterGlobalEventHandlers method

And call it when `converse.initialize` gets called again
This commit is contained in:
JC Brand 2018-12-15 19:52:45 +01:00
parent 003af0c438
commit 9ff505fd66
2 changed files with 13 additions and 0 deletions

7
dist/converse.js vendored
View File

@ -62948,6 +62948,12 @@ function finishInitialization() {
} }
} }
function unregisterGlobalEventHandlers() {
document.removeEventListener("visibilitychange", _converse.saveWindowState);
_converse.emit('registeredGlobalEventHandlers');
}
function cleanup() { function cleanup() {
// Looks like _converse.initialized was called again without logging // Looks like _converse.initialized was called again without logging
// out or disconnecting in the previous session. // out or disconnecting in the previous session.
@ -62956,6 +62962,7 @@ function cleanup() {
_converse.chatboxviews.closeAllChatBoxes(); _converse.chatboxviews.closeAllChatBoxes();
unregisterGlobalEventHandlers();
window.localStorage.clear(); window.localStorage.clear();
window.sessionStorage.clear(); window.sessionStorage.clear();

View File

@ -433,12 +433,18 @@ function finishInitialization () {
} }
function unregisterGlobalEventHandlers () {
document.removeEventListener("visibilitychange", _converse.saveWindowState);
_converse.emit('registeredGlobalEventHandlers');
}
function cleanup () { function cleanup () {
// Looks like _converse.initialized was called again without logging // Looks like _converse.initialized was called again without logging
// out or disconnecting in the previous session. // out or disconnecting in the previous session.
// This happens in tests. We therefore first clean up. // This happens in tests. We therefore first clean up.
Backbone.history.stop(); Backbone.history.stop();
_converse.chatboxviews.closeAllChatBoxes(); _converse.chatboxviews.closeAllChatBoxes();
unregisterGlobalEventHandlers();
window.localStorage.clear(); window.localStorage.clear();
window.sessionStorage.clear(); window.sessionStorage.clear();
if (_converse.bookmarks) { if (_converse.bookmarks) {