aboutsummaryrefslogtreecommitdiffstats
path: root/src/electron/ipc-api/dnd.ts
blob: d8958d9b0096d2983a49c030a6afbd1c1a4f5213 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { ipcMain } from 'electron';
import doNotDisturb from '@sindresorhus/do-not-disturb';
import { isMac } from '../../environment';

const debug = require('debug')('Ferdi:ipcApi:dnd');

export default async () => {
  ipcMain.handle('get-dnd', async () => {
    if (!isMac) {
      return false;
    }

    try {
      const isDND = await doNotDisturb.isEnabled();
      debug('Fetching DND state, set to', isDND);
      return isDND;
    } catch (error) {
      console.error(error);
      return false;
    }
  });
};