Fix unread counter not being formatted on page load
This commit is contained in:
parent
a2ca221577
commit
ed700ef504
9
client/js/libs/handlebars/roundBadgeNumber.js
Normal file
9
client/js/libs/handlebars/roundBadgeNumber.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
Handlebars.registerHelper(
|
||||||
|
"roundBadgeNumber", function(count) {
|
||||||
|
if (count < 1000) {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (count / 1000).toFixed(2).slice(0, -1) + "k";
|
||||||
|
}
|
||||||
|
);
|
@ -670,7 +670,7 @@ $(function() {
|
|||||||
self.addClass("active")
|
self.addClass("active")
|
||||||
.find(".badge")
|
.find(".badge")
|
||||||
.removeClass("highlight")
|
.removeClass("highlight")
|
||||||
.data("count", "")
|
.data("count", 0)
|
||||||
.empty();
|
.empty();
|
||||||
|
|
||||||
if (sidebar.find(".highlight").length === 0) {
|
if (sidebar.find(".highlight").length === 0) {
|
||||||
@ -845,7 +845,7 @@ $(function() {
|
|||||||
if (badge.length !== 0) {
|
if (badge.length !== 0) {
|
||||||
var i = (badge.data("count") || 0) + 1;
|
var i = (badge.data("count") || 0) + 1;
|
||||||
badge.data("count", i);
|
badge.data("count", i);
|
||||||
badge.html(i > 999 ? (i / 1000).toFixed(1) + "k" : i);
|
badge.html(Handlebars.helpers.roundBadgeNumber(i));
|
||||||
if (msg.highlight) {
|
if (msg.highlight) {
|
||||||
badge.addClass("highlight");
|
badge.addClass("highlight");
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{{#each channels}}
|
{{#each channels}}
|
||||||
<div data-id="{{id}}" data-target="#chan-{{id}}" data-title="{{name}}" class="chan {{type}}">
|
<div data-id="{{id}}" data-target="#chan-{{id}}" data-title="{{name}}" class="chan {{type}}">
|
||||||
<span class="badge{{#if highlight}} highlight{{/if}}" data-count="{{unread}}">{{#if unread}}{{unread}}{{/if}}</span>
|
<span class="badge{{#if highlight}} highlight{{/if}}" data-count="{{unread}}">{{#if unread}}{{roundBadgeNumber unread}}{{/if}}</span>
|
||||||
<button class="close" aria-label="Close"></button>
|
<button class="close" aria-label="Close"></button>
|
||||||
<span class="name" title="{{name}}">{{name}}</span>
|
<span class="name" title="{{name}}">{{name}}</span>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user