[IMP] mail: only display needactions in channel inbox

This commit is contained in:
Aaron Bohy
2015-10-02 15:49:37 +02:00
parent 8908d5ccab
commit 28d3dc6cc9
3 changed files with 23 additions and 14 deletions
+8 -7
View File
@@ -179,6 +179,7 @@ function make_channel (data, options) {
is_folded: data.state === "folded",
autoswitch: 'autoswitch' in options ? options.autoswitch : true,
hidden: options.hidden,
display_needactions: options.display_needactions,
cache: {'[]': {
all_history_loaded: false,
loaded: false,
@@ -410,15 +411,15 @@ var chat_manager = {
// ---------------------------------------------------------------------------------
function init () {
add_channel({
id: "channel_inbox",
name: _t("Inbox"),
type: "static"
});
id: "channel_inbox",
name: _t("Inbox"),
type: "static",
}, { display_needactions: true });
add_channel({
id: "channel_starred",
name: _t("Starred"),
type: "static"
id: "channel_starred",
name: _t("Starred"),
type: "static"
});
var load_channels = session.rpc('/mail/client_action').then(function (result) {
+4 -1
View File
@@ -27,7 +27,10 @@ return Widget.extend({
this.$content = this.$('.o_chat_content');
this.$input = this.$('.o_chat_input input');
this.thread = new ChatThread(this, {display_avatar: false});
this.thread = new ChatThread(this, {
display_avatar: false,
display_needactions: false,
});
this.thread.on('toggle_star_status', this, function (message_id) {
this.trigger('toggle_star_status', message_id);
});
+11 -6
View File
@@ -327,11 +327,17 @@ var ChatAction = Widget.extend(ControlPanelMixin, {
});
},
get_thread_rendering_options: function () {
return {
display_load_more: !chat_manager.all_history_loaded(this.channel, this.domain),
display_needactions: this.channel.display_needactions,
};
},
fetch_and_render_thread: function () {
var self = this;
return chat_manager.fetch(this.channel, this.domain).then(function(result) {
var history_loaded = chat_manager.all_history_loaded(self.channel, self.domain);
self.thread.render(result, {display_load_more: !history_loaded});
self.thread.render(result, self.get_thread_rendering_options());
});
},
@@ -343,8 +349,7 @@ var ChatAction = Widget.extend(ControlPanelMixin, {
return chat_manager
.fetch_more(this.channel, this.domain)
.then(function(result) {
var history_loaded = chat_manager.all_history_loaded(self.channel, self.domain);
self.thread.render(result, {display_load_more: !history_loaded});
self.thread.render(result, self.get_thread_rendering_options());
offset += framework.getPosition(document.querySelector(oldest_msg_selector)).top;
self.thread.scroll_to({offset: offset});
});
@@ -425,8 +430,8 @@ var ChatAction = Widget.extend(ControlPanelMixin, {
if ((current_channel_id === "channel_starred" && !message.is_starred) ||
(current_channel_id === "channel_inbox" && !message.is_needaction)) {
chat_manager.fetch(this.channel, this.domain).then(function (messages) {
var history_loaded = chat_manager.all_history_loaded(self.channel, self.domain);
self.thread.remove_message_and_render(message.id, messages, {display_load_more: !history_loaded});
var options = self.get_thread_rendering_options();
self.thread.remove_message_and_render(message.id, messages, options);
});
} else if (_.contains(message.channel_ids, current_channel_id)) {
this.fetch_and_render_thread();