diff options
| author | Lucas Lefèvre <lul@odoo.com> | 2019-01-29 09:36:00 +0000 |
|---|---|---|
| committer | Lucas Lefèvre <lul@odoo.com> | 2019-01-29 14:25:42 +0000 |
| commit | 95ef46096110512117a7b7dd9bc797732be36b26 (patch) | |
| tree | a6a1b6e6f5f8feff0b5955b05fde208918a763d6 /addons/mail/static/src/js/thread_windows/thread_window.js | |
| parent | e2e01013496961e3548bafb046f56f5db6bdfc8a (diff) | |
[FIX] mail: don't trigger if mail bus is undefined
Steps to reproduce the bug:
1. open an app such that there is a breadcrumb (e.g. an employee form view)
2. create a chat window with a user
3. click on the expand button to open the chat in Discuss
4. unsubscribe from the thread
5. click on the breadcrumb to go back
=> Traceback
When expanding the chat window to open Discuss, it registers a callback which
triggers an event on the mail bus. This callback is called when clicking
on the breadcrumb.
Because the channel was left, any related chat window is destroyed.
Since the widget is destroyed, it has no parent, so any service call
returns `undefined`, hence `getMailBus` returns `undefined`.
Fix: check if mailbus exists before triggering.
closes odoo/odoo#30640
Diffstat (limited to 'addons/mail/static/src/js/thread_windows/thread_window.js')
| -rw-r--r-- | addons/mail/static/src/js/thread_windows/thread_window.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/addons/mail/static/src/js/thread_windows/thread_window.js b/addons/mail/static/src/js/thread_windows/thread_window.js index 37cd673b053..49f4abf7f06 100644 --- a/addons/mail/static/src/js/thread_windows/thread_window.js +++ b/addons/mail/static/src/js/thread_windows/thread_window.js @@ -276,8 +276,10 @@ var ThreadWindow = AbstractThreadWindow.extend({ clear_breadcrumbs: false, active_id: this.hasThread() ? this._getThreadID() : undefined, on_reverse_breadcrumb: function () { - self.call('mail_service', 'getMailBus') - .trigger('discuss_open', false); + var mailBus = self.call('mail_service', 'getMailBus'); + if (mailBus) { + mailBus.trigger('discuss_open', false); + } }, }); } |
