From 3f90f2dd025572b6c06c609f7a800bc0561edd03 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Sat, 30 Apr 2022 21:41:49 -0500 Subject: Fix issue where 'macos-notification-state' was being loaded in non-macos --- src/electron/ipc-api/dnd.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/electron') diff --git a/src/electron/ipc-api/dnd.ts b/src/electron/ipc-api/dnd.ts index 6b1777367..9bef0fe3c 100644 --- a/src/electron/ipc-api/dnd.ts +++ b/src/electron/ipc-api/dnd.ts @@ -1,8 +1,6 @@ import { ipcMain } from 'electron'; import { isMac } from '../../environment'; -const { getDoNotDisturb } = require('macos-notification-state'); - const debug = require('../../preload-safe-debug')('Ferdium:ipcApi:dnd'); export default async () => { @@ -11,6 +9,14 @@ export default async () => { return false; } + // eslint-disable-next-line global-require + const { getDoNotDisturb } = require('macos-notification-state'); + + if (!getDoNotDisturb) { + debug("Could not load 'macos-notification-state' module"); + return false; + } + try { const isDND = getDoNotDisturb(); debug('Fetching DND state, set to', isDND); -- cgit v1.2.3-54-g00ecf