Revert mention count with ignoring 'badge-notify'
'badge-notify' counts also unread channels.
This commit is contained in:
@@ -4,6 +4,14 @@ const electron = require('electron');
|
|||||||
const ipc = electron.ipcRenderer;
|
const ipc = electron.ipcRenderer;
|
||||||
const NativeNotification = Notification;
|
const NativeNotification = Notification;
|
||||||
|
|
||||||
|
var hasClass = function(element, className) {
|
||||||
|
var rclass = /[\t\r\n\f]/g;
|
||||||
|
if ((' ' + element.className + ' ').replace(rclass, ' ').indexOf(className) > -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
var unreadCountTimer = setInterval(function() {
|
var unreadCountTimer = setInterval(function() {
|
||||||
if (!this.unreadCount) {
|
if (!this.unreadCount) {
|
||||||
this.unreadCount = 0;
|
this.unreadCount = 0;
|
||||||
@@ -15,11 +23,13 @@ var unreadCountTimer = setInterval(function() {
|
|||||||
// unreadCount in sidebar
|
// unreadCount in sidebar
|
||||||
// Note: the active channel doesn't have '.unread-title'.
|
// Note: the active channel doesn't have '.unread-title'.
|
||||||
var unreadCount = document.getElementsByClassName('unread-title').length;
|
var unreadCount = document.getElementsByClassName('unread-title').length;
|
||||||
// mentionCount in mobile navbar-toggle
|
// mentionCount in sidebar
|
||||||
var mentionBadge = document.getElementsByClassName('badge-notify');
|
var elem = document.getElementsByClassName('badge')
|
||||||
var mentionCount = 0;
|
var mentionCount = 0;
|
||||||
if (mentionBadge.length > 0) { // older mattermost doesn't have badges.
|
for (var i = 0; i < elem.length; i++) {
|
||||||
mentionCount = Number(mentionBadge[0].innerHTML);
|
if (isElementVisible(elem[i]) && !hasClass(elem[i], 'badge-notify')) {
|
||||||
|
mentionCount += Number(elem[i].innerHTML);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var postAttrName = 'data-reactid';
|
var postAttrName = 'data-reactid';
|
||||||
|
Reference in New Issue
Block a user