aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/nextcloud-talk/webview.js
blob: 42b1e49fe78dc21bebb5d1f7681dc2e6a80330a0 (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
26
27
28
29
"use strict";

var _path = _interopRequireDefault(require("path"));

function _interopRequireDefault(obj) {
  return obj && obj.__esModule ? obj : { default: obj };
}

module.exports = Ferdi => {
  const getMessages = function getMessages() {
    const direct =  document.querySelector(
      '.notifications .notification-wrapper'
    ).querySelectorAll(
      '.notification[object_type="chat"], .notification[object_type="room"'
    ).length;

    var indirect = 0;

    document.querySelectorAll('.app-navigation-entry__counter').forEach(
      function(counter) {
        indirect += Number(counter.textContent)
      }
    );
    Ferdi.setBadge(direct, indirect);
  };

  Ferdi.loop(getMessages);
  Ferdi.injectCSS(_path.default.join(__dirname, 'service.css'));
};