aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/rainloop/webview.js
blob: 346e51f7e5bfe282b2ecd80bb427cf5fc3f62b40 (plain) (blame)
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
module.exports = Ferdi => {
  const getMessages = () => {
    let updates = 0;
    let inbox = 0;
    let full = 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')) {
            inbox += Ferdi.safeParseInt(countText);
          }
        } else {
          updates += Ferdi.safeParseInt(countText);
        }
      }
    });

    full = inbox + updates;
    Ferdi.setBadge(full);
  };

  Ferdi.loop(getMessages);
};