blob: 577cd0448957352873ef8c4410289ef41d1f697f (
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
|
import { ipcMain } from 'electron';
import { isMac } from '../../environment';
const debug = require('../../preload-safe-debug')('Ferdium:ipcApi:dnd');
export default async () => {
ipcMain.handle('get-dnd', async () => {
if (!isMac) {
return false;
}
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
// @ts-ignore
const { getDoNotDisturb } = await import('macos-notification-state');
if (!getDoNotDisturb) {
debug("Could not load 'macos-notification-state' module");
return false;
}
try {
const isDND = await getDoNotDisturb();
debug('Fetching DND state, set to', isDND);
return isDND;
} catch (error) {
console.error(error);
return false;
}
});
};
|