Show badges when active channels have new messages

This commit is contained in:
Yuya Ochiai
2016-01-06 22:15:35 +09:00
parent b49f230060
commit 3e300c78d6

View File

@@ -8,7 +8,18 @@ var unreadCountTimer = setInterval(function() {
if (!this.count) {
this.count = 0;
}
// count in sidebar
var unreadCount = document.getElementsByClassName('unread-title').length;
// count for active channel
var newSeparators = document.getElementsByClassName('new-separator');
for (var i = 0; i < newSeparators.length; i++) {
if (newSeparators[i].offsetParent !== null) {
unreadCount += 1;
}
}
if (this.count != unreadCount) {
ipc.sendToHost('onUnreadCountChange', unreadCount);
}