From 085f6e0e6872cbfe2e4ee2c8db92bef0f1f23b8c Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Tue, 8 Dec 2015 15:45:09 +0100 Subject: [PATCH] [FIX] mail: multiple clicks on navbar needactions icon Clicking on this icon redirects to the client action (for now at least). By quickly clicking several times on it, we try to restore the scroll position of a channel that not yet exists. This rev. prevents from getting a traceback in that case. --- addons/mail/static/src/js/client_action.js | 4 +++- addons/mail/static/src/js/systray.js | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/mail/static/src/js/client_action.js b/addons/mail/static/src/js/client_action.js index fc9d73fbfb7..e06abc5a9de 100644 --- a/addons/mail/static/src/js/client_action.js +++ b/addons/mail/static/src/js/client_action.js @@ -120,7 +120,9 @@ var ChatAction = Widget.extend(ControlPanelMixin, { }, on_attach_callback: function () { - this.thread.scroll_to({offset: this.channels_scrolltop[this.channel.id]}); + if (this.channel) { + this.thread.scroll_to({offset: this.channels_scrolltop[this.channel.id]}); + } }, on_detach_callback: function () { this.channels_scrolltop[this.channel.id] = this.thread.get_scrolltop(); diff --git a/addons/mail/static/src/js/systray.js b/addons/mail/static/src/js/systray.js index c5d34f179bc..19e225c364f 100644 --- a/addons/mail/static/src/js/systray.js +++ b/addons/mail/static/src/js/systray.js @@ -29,11 +29,14 @@ var NotificationTopButton = Widget.extend({ }, on_click: function (event) { event.preventDefault(); + this.discuss_redirect(); + }, + discuss_redirect: _.debounce(function () { var discuss_ids = chat_manager.get_discuss_ids(); this.do_action(discuss_ids.action_id, {clear_breadcrumbs: true}).then(function () { core.bus.trigger('change_menu_section', discuss_ids.menu_id); }); - }, + }, 1000, true), }); SystrayMenu.Items.push(NotificationTopButton);