More proper unread messages detection.

parent 9be33238
......@@ -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');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment