Commit 6ec18345 authored by JC Brand's avatar JC Brand

Remove global event listener when appropriate.

Otherwise trimChats called in `fullscreen` tests (due to being
registered in a previous test)
parent 9ff505fd
......@@ -53176,15 +53176,17 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins
_converse.emit('minimizedChatsInitialized');
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
_converse.on('registeredGlobalEventHandlers', function () {
window.addEventListener("resize", _.debounce(function (ev) {
if (_converse.connection.connected) {
_converse.chatboxviews.trimChats();
}
}, 200));
});
const debouncedTrim = _.debounce(ev => {
if (_converse.connection.connected) {
_converse.chatboxviews.trimChats();
}
}, 200);
_converse.api.listen.on('registeredGlobalEventHandlers', () => window.addEventListener("resize", debouncedTrim));
_converse.api.listen.on('unregisteredGlobalEventHandlers', () => window.removeEventListener("resize", debouncedTrim));
_converse.on('controlBoxOpened', function (chatbox) {
_converse.api.listen.on('controlBoxOpened', function (chatbox) {
// Wrapped in anon method because at scan time, chatboxviews
// attr not set yet.
if (_converse.connection.connected) {
......@@ -62951,7 +62953,7 @@ function finishInitialization() {
function unregisterGlobalEventHandlers() {
document.removeEventListener("visibilitychange", _converse.saveWindowState);
_converse.emit('registeredGlobalEventHandlers');
_converse.emit('unregisteredGlobalEventHandlers');
}
function cleanup() {
......@@ -517,15 +517,15 @@ converse.plugins.add('converse-minimize', {
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
_converse.on('registeredGlobalEventHandlers', function () {
window.addEventListener("resize", _.debounce(function (ev) {
if (_converse.connection.connected) {
_converse.chatboxviews.trimChats();
}
}, 200));
});
const debouncedTrim = _.debounce(ev => {
if (_converse.connection.connected) {
_converse.chatboxviews.trimChats();
}
}, 200);
_converse.api.listen.on('registeredGlobalEventHandlers', () => window.addEventListener("resize", debouncedTrim));
_converse.api.listen.on('unregisteredGlobalEventHandlers', () => window.removeEventListener("resize", debouncedTrim));
_converse.on('controlBoxOpened', function (chatbox) {
_converse.api.listen.on('controlBoxOpened', function (chatbox) {
// Wrapped in anon method because at scan time, chatboxviews
// attr not set yet.
if (_converse.connection.connected) {
......
......@@ -435,7 +435,7 @@ function finishInitialization () {
function unregisterGlobalEventHandlers () {
document.removeEventListener("visibilitychange", _converse.saveWindowState);
_converse.emit('registeredGlobalEventHandlers');
_converse.emit('unregisteredGlobalEventHandlers');
}
function cleanup () {
......
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