[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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user