diff options
Diffstat (limited to 'recipes/kiwiirc/webview.js')
-rw-r--r-- | recipes/kiwiirc/webview.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/recipes/kiwiirc/webview.js b/recipes/kiwiirc/webview.js new file mode 100644 index 0000000..0c362f0 --- /dev/null +++ b/recipes/kiwiirc/webview.js | |||
@@ -0,0 +1,34 @@ | |||
1 | const _path = _interopRequireDefault(require('path')); | ||
2 | |||
3 | function _interopRequireDefault(obj) { | ||
4 | return obj && obj.__esModule ? obj : { default: obj }; | ||
5 | } | ||
6 | |||
7 | module.exports = Ferdium => { | ||
8 | const getMessages = function getMessages() { | ||
9 | // eslint-disable-next-line no-undef | ||
10 | const unreadChannelsCount = kiwi.state.networks.reduce((count, network) => { | ||
11 | return (count += network.buffers.filter(buffer => { | ||
12 | return !buffer.name.startsWith('*') && buffer.flags.unread !== 0; | ||
13 | }).length); | ||
14 | }, 0); | ||
15 | |||
16 | // eslint-disable-next-line no-undef | ||
17 | const mentionedChannelsCount = kiwi.state.networks.reduce((count, network) => { | ||
18 | return (count += network.buffers.filter(buffer => { | ||
19 | return ( | ||
20 | !buffer.name.startsWith('*') && | ||
21 | buffer.flags.unread !== 0 && | ||
22 | buffer.flags.highlight | ||
23 | ); | ||
24 | }).length); | ||
25 | }, 0); | ||
26 | |||
27 | // set Ferdium badges | ||
28 | Ferdium.setBadge(mentionedChannelsCount, unreadChannelsCount); | ||
29 | }; | ||
30 | |||
31 | Ferdium.loop(getMessages); | ||
32 | |||
33 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); | ||
34 | }; | ||