Skip to content
Snippets Groups Projects
Commit db1447d4 authored by Alexandre Kühn's avatar Alexandre Kühn
Browse files

[FIX] mail: messaging start when bus service is deployed


Before this commit, messaging.start() may crash due to bus service
not yet deployed.

This commit fixes the issue by ensuring `start()` is always called
when the bus service is deployed. To do so, we introduce a new
service (Messaging) that simply waits for bus service deployment
before invoking messaging start.

Task-2468483

closes odoo/odoo#66828

Signed-off-by: default avatarSébastien Theys (seb) <seb@odoo.com>
parent 89d52375
No related branches found
No related tags found
No related merge requests found
...@@ -2,8 +2,10 @@ odoo.define('mail/static/src/js/main.js', function (require) { ...@@ -2,8 +2,10 @@ odoo.define('mail/static/src/js/main.js', function (require) {
'use strict'; 'use strict';
const ModelManager = require('mail/static/src/model/model_manager.js'); const ModelManager = require('mail/static/src/model/model_manager.js');
const MessagingService = require('@mail/services/messaging/messaging')[Symbol.for("default")];
const env = require('web.commonEnv'); const env = require('web.commonEnv');
const { serviceRegistry } = require('web.core');
const { Store } = owl; const { Store } = owl;
const { EventBus } = owl.core; const { EventBus } = owl.core;
...@@ -121,6 +123,6 @@ env.bus.on( ...@@ -121,6 +123,6 @@ env.bus.on(
() => env.messagingBus.trigger('will_show_home_menu') () => env.messagingBus.trigger('will_show_home_menu')
); );
env.messagingCreatedPromise.then(() => env.messaging.start()); serviceRegistry.add('messaging', MessagingService);
}); });
/** @odoo-module **/
import AbstractService from 'web.AbstractService';
export default AbstractService.extend({
dependencies: ['bus_service'],
/**
* @override {web.AbstractService}
*/
start() {
this._super(...arguments);
this.env.messagingCreatedPromise.then(() => this.env.messaging.start());
},
});
...@@ -166,6 +166,7 @@ ...@@ -166,6 +166,7 @@
<script type="text/javascript" src="/mail/static/src/models/user/user.js"></script> <script type="text/javascript" src="/mail/static/src/models/user/user.js"></script>
<script type="text/javascript" src="/mail/static/src/services/chat_window_service/chat_window_service.js"></script> <script type="text/javascript" src="/mail/static/src/services/chat_window_service/chat_window_service.js"></script>
<script type="text/javascript" src="/mail/static/src/services/dialog_service/dialog_service.js"></script> <script type="text/javascript" src="/mail/static/src/services/dialog_service/dialog_service.js"></script>
<script type="text/javascript" src="/mail/static/src/services/messaging/messaging.js"/>
<script type="text/javascript" src="/mail/static/src/utils/deferred/deferred.js"></script> <script type="text/javascript" src="/mail/static/src/utils/deferred/deferred.js"></script>
<script type="text/javascript" src="/mail/static/src/utils/throttle/throttle.js"></script> <script type="text/javascript" src="/mail/static/src/utils/throttle/throttle.js"></script>
<script type="text/javascript" src="/mail/static/src/utils/timer/timer.js"></script> <script type="text/javascript" src="/mail/static/src/utils/timer/timer.js"></script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment