More proper unread messages detection.

This commit is contained in:
Stanislav Nikitin 2019-01-21 13:39:59 +05:00
parent 9be3323859
commit c8349a314f
No known key found for this signature in database
GPG Key ID: 106900B32F8192EE

View File

@ -6,8 +6,17 @@ const { shell } = require('electron')
// Unread mails check.
function checkForUnreads() {
unread = parseInt(document.title.split(' ')[0]);
if (typeof (unread) != NaN && unread > 0) {
//var unread = parseInt($(".mail-MessagesFilters-Item_unread .mail-LabelList-Item_count").html());
var unread = 0;
items = document.getElementsByClassName('mail-LabelList-Item_count');
for (var i = 0; i < items.length; i++) {
var unreadInt = parseInt(items[i].innerHTML);
if (typeof (unreadInt) != NaN && unreadInt > 0) {
unread += unreadInt;
}
}
if (unread > 0) {
ipc.send('has-unread', unread);
} else {
ipc.send('has-no-unread');