diff options
author | 2021-09-14 11:03:28 +0200 | |
---|---|---|
committer | 2021-09-14 11:03:28 +0200 | |
commit | 087113d8a1214ba4c7df03bfe66747d8d944280c (patch) | |
tree | 4d853a03057138dfa845cd6a7d91ccf63565a1a6 /src/electron/ipc-api/dnd.ts | |
parent | chore: codebase improvements (#1930) (diff) | |
download | ferdium-app-087113d8a1214ba4c7df03bfe66747d8d944280c.tar.gz ferdium-app-087113d8a1214ba4c7df03bfe66747d8d944280c.tar.zst ferdium-app-087113d8a1214ba4c7df03bfe66747d8d944280c.zip |
chore: convert JS to TS (#1934)
Diffstat (limited to 'src/electron/ipc-api/dnd.ts')
-rw-r--r-- | src/electron/ipc-api/dnd.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/electron/ipc-api/dnd.ts b/src/electron/ipc-api/dnd.ts new file mode 100644 index 000000000..6fb8999a3 --- /dev/null +++ b/src/electron/ipc-api/dnd.ts | |||
@@ -0,0 +1,23 @@ | |||
1 | import { ipcMain } from 'electron'; | ||
2 | import { getDoNotDisturb } from 'macos-notification-state'; | ||
3 | import { isMac } from '../../environment'; | ||
4 | |||
5 | const debug = require('debug')('Ferdi:ipcApi:dnd'); | ||
6 | |||
7 | export default async () => { | ||
8 | ipcMain.handle('get-dnd', async () => { | ||
9 | if (!isMac) { | ||
10 | debug('Not on macOS, returning', false); | ||
11 | return false; | ||
12 | } | ||
13 | |||
14 | try { | ||
15 | const isDND = getDoNotDisturb(); | ||
16 | debug('Fetching DND state, set to', isDND); | ||
17 | return isDND; | ||
18 | } catch (e) { | ||
19 | console.error(e); | ||
20 | return false; | ||
21 | } | ||
22 | }); | ||
23 | }; | ||