From 89ba0a811b9cb10ba6747487eb97a35e3300a924 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Wed, 16 Dec 2015 12:20:00 +0100 Subject: [PATCH] [FIX] mail: traceback on new msg in unpinned closed livechat The traceback ocurred when the operator closed a livechat channel chat window, and then unpinned it from the sidebar in Discuss. Then, if the visitor sent him a message, the channel was automatically re-pinned to the operator, who received two notifications: the first one being the new channel info and the second one the message itself. The channel fold_state being 'closed', the window manager was trying to close it again, which produces the traceback as the channel didn't exist in the JS cache anymore (it was re-added to the cache when processing the message notification, so just after). Anyway, closing this channel was useless as, even if it was in the cache, it would already been closed. So this rev. simply checks whether or not the channel is in the cache before trying to close it. --- addons/mail/static/src/js/chat_manager.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/mail/static/src/js/chat_manager.js b/addons/mail/static/src/js/chat_manager.js index b91113ea9c6..909a4a0ff5b 100644 --- a/addons/mail/static/src/js/chat_manager.js +++ b/addons/mail/static/src/js/chat_manager.js @@ -509,6 +509,7 @@ function on_mark_as_unread_notification (data) { } function on_chat_session_notification (chat_session) { + var channel; if ((chat_session.channel_type === "channel") && (chat_session.state === "open")) { add_channel(chat_session, {autoswitch: false}); if (!chat_session.is_minimized && chat_session.info !== 'creation') { @@ -517,12 +518,15 @@ function on_chat_session_notification (chat_session) { } // partner specific change (open a detached window for example) if ((chat_session.state === "open") || (chat_session.state === "folded")) { - var channel = chat_session.is_minimized && chat_manager.get_channel(chat_session.id); + channel = chat_session.is_minimized && chat_manager.get_channel(chat_session.id); if (channel) { chat_manager.bus.trigger("open_chat", channel); } } else if (chat_session.state === "closed") { - chat_manager.bus.trigger("close_chat", chat_manager.get_channel(chat_session.id)); + channel = chat_manager.get_channel(chat_session.id); + if (channel) { + chat_manager.bus.trigger("close_chat", channel); + } } }