diff --git a/src/main/app/initialize.test.js b/src/main/app/initialize.test.js index 79577b2d..f71e6da7 100644 --- a/src/main/app/initialize.test.js +++ b/src/main/app/initialize.test.js @@ -50,6 +50,8 @@ jest.mock('electron', () => ({ on: jest.fn(), handle: jest.fn(), emit: jest.fn(), + removeHandler: jest.fn(), + removeListener: jest.fn(), }, screen: { on: jest.fn(), diff --git a/src/main/downloadsManager.test.js b/src/main/downloadsManager.test.js index 913b24c5..607eb6ce 100644 --- a/src/main/downloadsManager.test.js +++ b/src/main/downloadsManager.test.js @@ -40,6 +40,8 @@ jest.mock('electron', () => { emit: jest.fn(), handle: jest.fn(), on: jest.fn(), + removeHandler: jest.fn(), + removeListener: jest.fn(), }, Menu: { getApplicationMenu: () => ({ diff --git a/src/main/downloadsManager.ts b/src/main/downloadsManager.ts index 0e7f6c97..e974d89c 100644 --- a/src/main/downloadsManager.ts +++ b/src/main/downloadsManager.ts @@ -77,9 +77,21 @@ export class DownloadsManager extends JsonFileManager { this.checkForDeletedFiles(); this.reloadFilesForMAS(); + this.loadIPCHandlers(); + }; + + private loadIPCHandlers = () => { + ipcMain.removeHandler(REQUEST_HAS_DOWNLOADS); ipcMain.handle(REQUEST_HAS_DOWNLOADS, () => { return this.hasDownloads(); }); + + ipcMain.removeListener(DOWNLOADS_DROPDOWN_FOCUSED, this.clearAutoCloseTimeout); + ipcMain.removeListener(UPDATE_AVAILABLE, this.onUpdateAvailable); + ipcMain.removeListener(UPDATE_DOWNLOADED, this.onUpdateDownloaded); + ipcMain.removeListener(UPDATE_PROGRESS, this.onUpdateProgress); + ipcMain.removeListener(NO_UPDATE_AVAILABLE, this.noUpdateAvailable); + ipcMain.on(DOWNLOADS_DROPDOWN_FOCUSED, this.clearAutoCloseTimeout); ipcMain.on(UPDATE_AVAILABLE, this.onUpdateAvailable); ipcMain.on(UPDATE_DOWNLOADED, this.onUpdateDownloaded); diff --git a/src/main/menus/app.test.js b/src/main/menus/app.test.js index b2d23dff..c6b55daf 100644 --- a/src/main/menus/app.test.js +++ b/src/main/menus/app.test.js @@ -32,6 +32,8 @@ jest.mock('electron', () => { emit: jest.fn(), handle: jest.fn(), on: jest.fn(), + removeHandler: jest.fn(), + removeListener: jest.fn(), }, Notification: NotificationMock, }; diff --git a/src/main/views/downloadsDropdownMenuView.test.js b/src/main/views/downloadsDropdownMenuView.test.js index 3a7bacd2..24a7cf25 100644 --- a/src/main/views/downloadsDropdownMenuView.test.js +++ b/src/main/views/downloadsDropdownMenuView.test.js @@ -41,6 +41,8 @@ jest.mock('electron', () => { emit: jest.fn(), handle: jest.fn(), on: jest.fn(), + removeHandler: jest.fn(), + removeListener: jest.fn(), }, Notification: NotificationMock, }; diff --git a/src/main/views/downloadsDropdownView.test.js b/src/main/views/downloadsDropdownView.test.js index 56320c90..d4281d59 100644 --- a/src/main/views/downloadsDropdownView.test.js +++ b/src/main/views/downloadsDropdownView.test.js @@ -53,6 +53,8 @@ jest.mock('electron', () => { emit: jest.fn(), handle: jest.fn(), on: jest.fn(), + removeHandler: jest.fn(), + removeListener: jest.fn(), }, Notification: NotificationMock, };