[FIX] mail: prevent race conditions when joining channels

it should now be impossible to join a channel several times when loading
a browser tab
This commit is contained in:
Géry Debongnie
2015-11-16 09:51:09 +01:00
committed by Aaron Bohy
parent 856743fd06
commit e1727c98fe
+7 -1
View File
@@ -19,6 +19,7 @@ var ChannelModel = new Model('mail.channel', session.context);
//----------------------------------------------------------------------------------
var messages = [];
var channels = [];
var channel_defs = {};
var emojis = [];
var emoji_substitutions = {};
var needaction_counter = 0;
@@ -535,11 +536,16 @@ var chat_manager = {
.then(add_channel);
},
join_channel: function (channel_id, options) {
return ChannelModel
if (channel_id in channel_defs) {
return channel_defs[channel_id];
}
var def = ChannelModel
.call('channel_join_and_get_info', [[channel_id]])
.then(function (result) {
add_channel(result, options);
});
channel_defs[channel_id] = def;
return def;
},
unsubscribe: function (channel) {