aboutsummaryrefslogtreecommitdiffstats
path: root/src/webview/badge.ts
blob: b33d05255f2f0b39b2d661142f48aedd6d1cfcbb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { ipcRenderer } from 'electron';
import { safeParseInt } from '../jsUtils';

const debug = require('../preload-safe-debug')('Ferdium:Plugin:BadgeHandler');

export default class BadgeHandler {
  setBadge(
    direct: string | number | undefined | null,
    indirect: string | number | undefined | null,
  ) {
    const count = {
      direct: safeParseInt(direct),
      indirect: safeParseInt(indirect),
    };

    debug('Sending badge count to host: %j', count);
    ipcRenderer.sendToHost('message-counts', count);
  }
}