[IMP] mail: batch RPCs at init
Remove the RPC to retrieve the action_id of the client action as do_action() can take directly the xml_id, and batch the RPC to retrieve the menu_id with the initial RPC used to fetch channel slots, emojis...
This commit is contained in:
@@ -245,5 +245,6 @@ class MailController(http.Controller):
|
||||
'channel_slots': request.env['mail.channel'].channel_fetch_slot(),
|
||||
'mention_partner_suggestions': request.env['res.partner'].get_static_mention_suggestions(),
|
||||
'emoji': request.env['mail.shortcode'].sudo().search_read([('shortcode_type', '=', 'image')], ['source', 'substitution', 'description']),
|
||||
'menu_id': request.env['ir.model.data'].xmlid_to_res_id('mail.mail_channel_menu_root_chat'),
|
||||
}
|
||||
return values
|
||||
|
||||
@@ -31,7 +31,7 @@ var emojis = [];
|
||||
var emoji_substitutions = {};
|
||||
var needaction_counter = 0;
|
||||
var mention_partner_suggestions = [];
|
||||
var discuss_ids = {};
|
||||
var discuss_menu_id;
|
||||
var global_unread_counter = 0;
|
||||
var pinned_dm_partners = []; // partner_ids we have a pinned DM with
|
||||
var client_action_open = false;
|
||||
@@ -855,8 +855,8 @@ var chat_manager = {
|
||||
}
|
||||
},
|
||||
|
||||
get_discuss_ids: function () {
|
||||
return discuss_ids;
|
||||
get_discuss_menu_id: function () {
|
||||
return discuss_menu_id;
|
||||
},
|
||||
|
||||
detach_channel: function (channel) {
|
||||
@@ -1035,7 +1035,9 @@ function init () {
|
||||
type: "static"
|
||||
});
|
||||
|
||||
var load_channels = session.rpc('/mail/client_action').then(function (result) {
|
||||
bus.on('notification', null, on_notification);
|
||||
|
||||
return session.rpc('/mail/client_action').then(function (result) {
|
||||
_.each(result.channel_slots, function (channels) {
|
||||
_.each(channels, add_channel);
|
||||
});
|
||||
@@ -1045,19 +1047,8 @@ function init () {
|
||||
_.each(emojis, function(emoji) {
|
||||
emoji_substitutions[_.escape(emoji.source)] = emoji.substitution;
|
||||
});
|
||||
});
|
||||
discuss_menu_id = result.menu_id;
|
||||
|
||||
var ir_model = new Model("ir.model.data");
|
||||
var load_menu_id = ir_model.call("xmlid_to_res_id", ["mail.mail_channel_menu_root_chat"], {}, {shadow: true});
|
||||
var load_action_id = ir_model.call("xmlid_to_res_id", ["mail.mail_channel_action_client_chat"], {}, {shadow: true});
|
||||
|
||||
bus.on('notification', null, on_notification);
|
||||
|
||||
return $.when(load_menu_id, load_action_id, load_channels).then(function (menu_id, action_id) {
|
||||
discuss_ids = {
|
||||
menu_id: menu_id,
|
||||
action_id: action_id,
|
||||
};
|
||||
bus.start_polling();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -813,8 +813,7 @@ var Chatter = form_common.AbstractField.extend({
|
||||
var def = chat_manager.join_channel(channel_id);
|
||||
$.when(def).then(function () {
|
||||
// Execute Discuss client action with 'channel' as default channel
|
||||
var discuss_ids = chat_manager.get_discuss_ids();
|
||||
self.do_action(discuss_ids.action_id, {active_id: channel_id});
|
||||
self.do_action('mail.mail_channel_action_client_chat', {active_id: channel_id});
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -35,10 +35,9 @@ var InboxItem = Widget.extend({
|
||||
},
|
||||
discuss_redirect: _.debounce(function () {
|
||||
var self = this;
|
||||
var discuss_ids = chat_manager.get_discuss_ids();
|
||||
this.do_action(discuss_ids.action_id, {clear_breadcrumbs: true}).then(function () {
|
||||
this.do_action('mail.mail_channel_action_client_chat', {clear_breadcrumbs: true}).then(function () {
|
||||
self.trigger_up('hide_app_switcher');
|
||||
core.bus.trigger('change_menu_section', discuss_ids.menu_id);
|
||||
core.bus.trigger('change_menu_section', chat_manager.get_discuss_menu_id());
|
||||
});
|
||||
}, 1000, true),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user