[FIX] mail: prevent race condition in client action
The issue was that the chat_manager was an async js module, so it could be loaded quite late. Then the client action was loaded only after the chat_manager was ready, and possibly before the action_manager read the value in the action registry. This commits prevent this problem from happening by turning the chat manager into a sync module, so the chatter and the client action needs to wait for him to be ready before doing their magic.
This commit is contained in:
@@ -524,10 +524,11 @@ function init () {
|
||||
action_id: action_id,
|
||||
};
|
||||
bus.start_polling();
|
||||
return chat_manager;
|
||||
});
|
||||
}
|
||||
|
||||
return init();
|
||||
chat_manager.is_ready = init();
|
||||
|
||||
return chat_manager;
|
||||
|
||||
});
|
||||
|
||||
@@ -12,7 +12,6 @@ var data = require('web.data');
|
||||
var Dialog = require('web.Dialog');
|
||||
var form_common = require('web.form_common');
|
||||
var session = require('web.session');
|
||||
var web_client = require('web.web_client');
|
||||
|
||||
var _t = core._t;
|
||||
var qweb = core.qweb;
|
||||
@@ -696,6 +695,10 @@ var Chatter = form_common.AbstractField.extend({
|
||||
this.context = this.options.context || {};
|
||||
},
|
||||
|
||||
willStart: function () {
|
||||
return chat_manager.is_ready;
|
||||
},
|
||||
|
||||
start: function () {
|
||||
var self = this;
|
||||
|
||||
|
||||
@@ -127,6 +127,10 @@ var ChatAction = Widget.extend(ControlPanelMixin, {
|
||||
this.channels_scrolltop = {};
|
||||
},
|
||||
|
||||
willStart: function () {
|
||||
return chat_manager.is_ready;
|
||||
},
|
||||
|
||||
start: function() {
|
||||
var self = this;
|
||||
|
||||
|
||||
@@ -106,10 +106,12 @@ core.bus.on('web_client_ready', null, function () {
|
||||
});
|
||||
});
|
||||
|
||||
_.each(chat_manager.get_channels(), function (channel) {
|
||||
if (channel.is_detached) {
|
||||
open_chat(channel);
|
||||
}
|
||||
chat_manager.is_ready.then(function() {
|
||||
_.each(chat_manager.get_channels(), function (channel) {
|
||||
if (channel.is_detached) {
|
||||
open_chat(channel);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user