fix: #7167, composer and chat not closing on logout

v1.18.x
Julian Lam 6 years ago
parent 43e7cc0afb
commit 629b35546c

@ -258,6 +258,12 @@ define('chat', [
}
};
// TODO: see taskbar.js:44
module.closeByUUID = function (uuid) {
var chatModal = $('.chat-modal[data-uuid="' + uuid + '"]');
module.close(chatModal);
};
module.center = function (chatModal) {
var hideAfter = false;
if (chatModal.hasClass('hide')) {

@ -34,6 +34,42 @@ define('taskbar', ['benchpress', 'translator'], function (Benchpress, translator
return false;
});
});
$(window).on('action:app.loggedOut', function () {
taskbar.closeAll();
});
};
taskbar.close = function (module, uuid) {
// Sends signal to the appropriate module's .close() fn (if present)
var btnEl = taskbar.tasklist.find('[data-module="' + module + '"][data-uuid="' + uuid + '"]');
var fnName = 'close';
// TODO: Refactor chat module to not take uuid in close instead of by jQuery element
if (module === 'chat') {
fnName = 'closeByUUID';
}
if (btnEl.length) {
require([module], function (module) {
if (typeof module[fnName] === 'function') {
module[fnName](uuid);
}
});
}
};
taskbar.closeAll = function (module) {
// module is optional
var selector = '[data-uuid]';
if (module) {
selector = '[data-module="' + module + '"]' + selector;
}
taskbar.tasklist.find(selector).each(function (idx, el) {
taskbar.close(module || el.getAttribute('data-module'), el.getAttribute('data-uuid'));
});
};
taskbar.discard = function (module, uuid) {

Loading…
Cancel
Save