forked from meetfranz/plugins-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebview.js
More file actions
31 lines (27 loc) · 1.02 KB
/
webview.js
File metadata and controls
31 lines (27 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const path = require('path');
module.exports = (Franz, options) => {
const getMessages = () => {
let updates = 0;
let inbox = 0;
$('.b-folders-user .ui-droppable').each((i, obj) => {
const countText = $(obj).find('.count').first().html();
if (typeof countText === 'string' && countText !== '') {
if ($(obj).hasClass('system')) {
if ($(obj).hasClass('i-am-inbox')) {
// only get messages in 'Inbox', not other system folders
inbox += parseInt(countText);
}
} else {
// get unread messages from folders
updates += parseInt(countText);
}
}
});
// set Franz badge
// inbox => active unread count
// updates => passive unread count
Franz.setBadge(inbox, updates);
};
// check for new messages every second and update Franz badge
Franz.loop(getMessages);
};