aboutsummaryrefslogtreecommitdiffstats
path: root/src/electron/ipc-api
diff options
context:
space:
mode:
Diffstat (limited to 'src/electron/ipc-api')
-rw-r--r--src/electron/ipc-api/cld.ts4
-rw-r--r--src/electron/ipc-api/dnd.ts5
2 files changed, 6 insertions, 3 deletions
diff --git a/src/electron/ipc-api/cld.ts b/src/electron/ipc-api/cld.ts
index 4221f9b22..5e958b102 100644
--- a/src/electron/ipc-api/cld.ts
+++ b/src/electron/ipc-api/cld.ts
@@ -5,6 +5,9 @@ const debug = require('debug')('Ferdi:ipcApi:cld');
5 5
6export default async () => { 6export default async () => {
7 ipcMain.handle('detect-language', async (_event, { sample }) => { 7 ipcMain.handle('detect-language', async (_event, { sample }) => {
8 if (!cld) {
9 return null;
10 }
8 try { 11 try {
9 const result = await cld.detect(sample); 12 const result = await cld.detect(sample);
10 debug('Checking language', 'probability', result.languages); 13 debug('Checking language', 'probability', result.languages);
@@ -18,6 +21,7 @@ export default async () => {
18 } 21 }
19 } catch (error) { 22 } catch (error) {
20 console.error(error); 23 console.error(error);
24 return null;
21 } 25 }
22 }); 26 });
23}; 27};
diff --git a/src/electron/ipc-api/dnd.ts b/src/electron/ipc-api/dnd.ts
index afaef9a66..d8958d9b0 100644
--- a/src/electron/ipc-api/dnd.ts
+++ b/src/electron/ipc-api/dnd.ts
@@ -1,5 +1,5 @@
1import { ipcMain } from 'electron'; 1import { ipcMain } from 'electron';
2import { getDoNotDisturb } from 'macos-notification-state'; 2import doNotDisturb from '@sindresorhus/do-not-disturb';
3import { isMac } from '../../environment'; 3import { isMac } from '../../environment';
4 4
5const debug = require('debug')('Ferdi:ipcApi:dnd'); 5const debug = require('debug')('Ferdi:ipcApi:dnd');
@@ -7,12 +7,11 @@ const debug = require('debug')('Ferdi:ipcApi:dnd');
7export default async () => { 7export default async () => {
8 ipcMain.handle('get-dnd', async () => { 8 ipcMain.handle('get-dnd', async () => {
9 if (!isMac) { 9 if (!isMac) {
10 debug('Not on macOS, returning', false);
11 return false; 10 return false;
12 } 11 }
13 12
14 try { 13 try {
15 const isDND = getDoNotDisturb(); 14 const isDND = await doNotDisturb.isEnabled();
16 debug('Fetching DND state, set to', isDND); 15 debug('Fetching DND state, set to', isDND);
17 return isDND; 16 return isDND;
18 } catch (error) { 17 } catch (error) {