diff --git a/main.js b/main.js index 8de0d1902..dd9803100 100644 --- a/main.js +++ b/main.js @@ -67,6 +67,7 @@ menubarApp.on('ready', () => { }); ipcMain.on('reopen-window', () => menubarApp.showWindow()); + ipcMain.on('hide-window', () => menubarApp.hideWindow()); ipcMain.on('app-quit', () => menubarApp.app.quit()); ipcMain.on('update-icon', (_, arg) => { if (!menubarApp.tray.isDestroyed()) { diff --git a/src/utils/auth.ts b/src/utils/auth.ts index a5d3d405d..96d83242f 100644 --- a/src/utils/auth.ts +++ b/src/utils/auth.ts @@ -1,7 +1,6 @@ -import { generateGitHubAPIUrl } from './helpers'; - -const { BrowserWindow } = require('@electron/remote'); +import { BrowserWindow } from '@electron/remote'; +import { generateGitHubAPIUrl } from './helpers'; import { apiRequest, apiRequestAuth } from '../utils/api-requests'; import { AuthResponse, AuthState, AuthTokenResponse } from '../types'; import { Constants } from '../utils/constants'; diff --git a/src/utils/comms.test.ts b/src/utils/comms.test.ts index 8a5c5af83..23e3c1fec 100644 --- a/src/utils/comms.test.ts +++ b/src/utils/comms.test.ts @@ -1,3 +1,5 @@ +import { ipcRenderer, shell } from 'electron'; +import remote from '@electron/remote'; import { updateTrayIcon, openExternalLink, @@ -5,10 +7,6 @@ import { restoreSetting, } from './comms'; -const { ipcRenderer, shell } = require('electron'); - -const remote = require('@electron/remote'); - describe('utils/comms.ts', () => { beforeEach(function () { jest.spyOn(ipcRenderer, 'send'); diff --git a/src/utils/comms.ts b/src/utils/comms.ts index 0f7f4e25a..513073b00 100644 --- a/src/utils/comms.ts +++ b/src/utils/comms.ts @@ -1,5 +1,5 @@ -const { ipcRenderer, shell } = require('electron'); -const remote = require('@electron/remote'); +import { ipcRenderer, shell } from 'electron'; +import remote from '@electron/remote'; export function openExternalLink(url: string): void { shell.openExternal(url); diff --git a/src/utils/notifications.ts b/src/utils/notifications.ts index 40f9e80c1..67431832c 100644 --- a/src/utils/notifications.ts +++ b/src/utils/notifications.ts @@ -1,6 +1,4 @@ import { ipcRenderer } from 'electron'; -const remote = require('@electron/remote'); - import { openInBrowser } from '../utils/helpers'; import { updateTrayIcon } from './comms'; import { Notification } from '../typesGithub'; @@ -84,7 +82,7 @@ export const raiseNativeNotification = ( nativeNotification.onclick = function () { if (notifications.length === 1) { - remote.getCurrentWindow().hide(); + ipcRenderer.send('hide-window'); openInBrowser(notifications[0], accounts); } else { ipcRenderer.send('reopen-window');