diff --git a/addons/web_im/static/src/js/im.js b/addons/web_im/static/src/js/im.js index 9cb70e7d21c..87a048dd14a 100644 --- a/addons/web_im/static/src/js/im.js +++ b/addons/web_im/static/src/js/im.js @@ -353,6 +353,7 @@ openerp.web_im = function(instance) { this.user.add_watcher(); this.set("right_position", 0); this.shown = true; + this.set("pending", 0); }, start: function() { var change_status = function() { @@ -366,6 +367,13 @@ openerp.web_im = function(instance) { this.on("change:right_position", this, this.calc_pos); this.full_height = this.$el.height(); this.calc_pos(); + this.on("change:pending", this, _.bind(function() { + if (this.get("pending") === 0) { + this.$(".oe_im_chatview_nbr_messages").text(""); + } else { + this.$(".oe_im_chatview_nbr_messages").text("(" + this.get("pending") + ")"); + } + }, this)); }, show_hide: function() { if (this.shown) { @@ -378,11 +386,19 @@ openerp.web_im = function(instance) { }); } this.shown = ! this.shown; + if (this.shown) { + this.set("pending", 0); + } }, calc_pos: function() { this.$el.css("right", this.get("right_position")); }, received_message: function(message) { + if (this.shown) { + this.set("pending", 0); + } else { + this.set("pending", this.get("pending") + 1); + } this._add_bubble(this.user, message.message, message.date); }, send_message: function(e) { diff --git a/addons/web_im/static/src/xml/im.xml b/addons/web_im/static/src/xml/im.xml index 118bbd85f13..3d42c717174 100644 --- a/addons/web_im/static/src/xml/im.xml +++ b/addons/web_im/static/src/xml/im.xml @@ -32,6 +32,7 @@