summaryrefslogtreecommitdiff
path: root/addons/mail/static/src
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2015-11-09 15:38:55 +0100
committerGéry Debongnie <ged@odoo.com>2015-11-09 16:28:06 +0100
commitfb013ce292bc0fdb4a2031de63ff56308471dfe4 (patch)
treedb012478b5646fc532a62ca0f4c6ec77ed3ac352 /addons/mail/static/src
parent9f6f5fe512efa6c3074e227b6318cad830c73003 (diff)
[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.
Diffstat (limited to 'addons/mail/static/src')
-rw-r--r--addons/mail/static/src/js/chat_manager.js5
-rw-r--r--addons/mail/static/src/js/chatter.js5
-rw-r--r--addons/mail/static/src/js/client_action.js4
-rw-r--r--addons/mail/static/src/js/window_manager.js10
4 files changed, 17 insertions, 7 deletions
diff --git a/addons/mail/static/src/js/chat_manager.js b/addons/mail/static/src/js/chat_manager.js
index 7fd42ef417c..9115ea995c8 100644
--- a/addons/mail/static/src/js/chat_manager.js
+++ b/addons/mail/static/src/js/chat_manager.js
@@ -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;
});
diff --git a/addons/mail/static/src/js/chatter.js b/addons/mail/static/src/js/chatter.js
index 0d261ea9053..5b98786ccdc 100644
--- a/addons/mail/static/src/js/chatter.js
+++ b/addons/mail/static/src/js/chatter.js
@@ -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;
diff --git a/addons/mail/static/src/js/client_action.js b/addons/mail/static/src/js/client_action.js
index 78e5cca529f..9a0f6f914d1 100644
--- a/addons/mail/static/src/js/client_action.js
+++ b/addons/mail/static/src/js/client_action.js
@@ -127,6 +127,10 @@ var ChatAction = Widget.extend(ControlPanelMixin, {
this.channels_scrolltop = {};
},
+ willStart: function () {
+ return chat_manager.is_ready;
+ },
+
start: function() {
var self = this;
diff --git a/addons/mail/static/src/js/window_manager.js b/addons/mail/static/src/js/window_manager.js
index 4ba8cc23a68..5c9a24b6dc5 100644
--- a/addons/mail/static/src/js/window_manager.js
+++ b/addons/mail/static/src/js/window_manager.js
@@ -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);
+ }
+ });
});
});