From: Darren Date: Mon, 11 Aug 2014 20:10:13 +0000 (+0100) Subject: Truncating unread message counter when > 999 #578 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=31fe7a446b82e1190ba09e43b2f063ca7b9852cc;p=KiwiIRC.git Truncating unread message counter when > 999 #578 --- 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();