From 31fe7a446b82e1190ba09e43b2f063ca7b9852cc Mon Sep 17 00:00:00 2001 From: Darren Date: Mon, 11 Aug 2014 21:10:13 +0100 Subject: [PATCH] Truncating unread message counter when > 999 #578 --- client/src/views/channel.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/client/src/views/channel.js b/client/src/views/channel.js index 940cb90..836455e 100644 --- a/client/src/views/channel.js +++ b/client/src/views/channel.js @@ -109,7 +109,7 @@ _kiwi.view.Channel = _kiwi.view.Panel.extend({ var $act = this.model.tab.find('.activity'), count_all_activity = _kiwi.global.settings.get('count_all_activity'), - exclude_message_types; + exclude_message_types, new_count; // Set the default config value if (typeof count_all_activity === 'undefined') { @@ -127,14 +127,23 @@ _kiwi.view.Channel = _kiwi.view.Panel.extend({ ]; if (count_all_activity || _.indexOf(exclude_message_types, msg.type) === -1) { - $act.text((parseInt($act.text(), 10) || 0) + 1); - } + new_count = $act.data('unread_counter') || 0; + new_count++; + $act.data('unread_counter', new_count); + + if (new_count > 999) { + $act.text('999+'); + } else { + $act.text(new_count); + } - if ($act.text() === '0') { - $act.addClass('zero'); - } else { - $act.removeClass('zero'); + if (new_count === 0) { + $act.addClass('zero'); + } else { + $act.removeClass('zero'); + } } + }).apply(this); if(this.model.isActive()) this.scrollToBottom(); -- 2.25.1