Browse Source

[REF] Replaced code from mail_move_message.js to remove_from_cache() method to base.js for reuse

pull/36/head
x620 9 years ago
parent
commit
79a7b4386d
  1. 14
      mail_base/static/src/js/base.js
  2. 12
      mail_move_message/static/src/js/mail_move_message.js

14
mail_base/static/src/js/base.js

@ -495,6 +495,20 @@ var MailTools = core.Class.extend({
});
},
remove_from_cache: function(message, domain){
var self = this;
_.each(message.channel_ids, function (channel_id) {
var channel = chat_manager.get_channel(channel_id);
if (channel) {
var channel_cache = self.get_channel_cache(channel, domain);
var index = _.sortedIndex(channel_cache.messages, message, 'id');
if (channel_cache.messages[index] === message) {
channel_cache.messages.splice(index, 1);
}
}
});
},
remove_message_from_channel: function (channel_id, message) {
message.channel_ids = _.without(message.channel_ids, channel_id);
var channel = _.findWhere(channels, { id: channel_id });

12
mail_move_message/static/src/js/mail_move_message.js

@ -73,17 +73,7 @@ odoo.define('mail_move_message.relocate', function (require) {
// Call ChatAction.on_update_message(message)
chat_manager.bus.trigger('update_message', message);
} else if (model === 'mail_move_message.delete_message') {
// Remove message from cache
_.each(message.channel_ids, function (channel_id) {
var channel = chat_manager.get_channel(channel_id);
if (channel) {
var channel_cache = self.get_channel_cache(channel, []);
var index = _.sortedIndex(channel_cache.messages, message, 'id');
if (channel_cache.messages[index] === message) {
channel_cache.messages.splice(index, 1);
}
}
});
self.remove_from_cache(message, []);
chat_manager.bus.trigger('update_message', message);
}
});

Loading…
Cancel
Save