Fix mention count becomes twice or unexpected string

1. 'badge-notify' exists on navbar-toggle in mobile layout.
   It has also 'badge' class, so the mention count became twice.
2. [] accessor was missing in counting.
This commit is contained in:
Yuya Ochiai
2016-02-02 01:10:14 +09:00
parent fc0459ee29
commit 929e5e6f88
2 changed files with 5 additions and 7 deletions

View File

@@ -170,7 +170,7 @@ var TabBar = React.createClass({
mentionCount = thisObj.props.mentionCounts[index];
}
if (thisObj.props.mentionAtActiveCounts[index] > 0) {
mentionCount += thisObj.props.mentionAtActiveCounts;
mentionCount += thisObj.props.mentionAtActiveCounts[index];
}
var badge;

View File

@@ -15,13 +15,11 @@ var unreadCountTimer = setInterval(function() {
// unreadCount in sidebar
// Note: the active channel doesn't have '.unread-title'.
var unreadCount = document.getElementsByClassName('unread-title').length;
// mentionCount in sidebar
var elem = document.getElementsByClassName('badge')
// mentionCount in mobile navbar-toggle
var mentionBadge = document.getElementsByClassName('badge-notify');
var mentionCount = 0;
for (var i = 0; i < elem.length; i++) {
if (isElementVisible(elem[i])) {
mentionCount += Number(elem[i].innerHTML);
}
if (mentionBadge.length > 0) { // older mattermost doesn't have badges.
mentionCount = Number(mentionBadge[0].innerHTML);
}
var postAttrName = 'data-reactid';