Remove WindowManager, separate functionality into smaller modules (#2682)

* Move sendToRenderer to respective singletons

* Move to using ViewManager call for getting view by webContentsId

* Move show and create logic to main window, handle deep linking seperately

* Move resizing logic and event handing to mainWindow

* Move server switching logic to main/app

* Move tab switching logic to main/app, rely on showById for most usage

* Migrate remaining functions, remove windowManager objects, set up imports for self-contained singletons

* Fix E2E tests

* Update src/main/app/servers.ts

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>

---------

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
This commit is contained in:
Devin Binnie
2023-04-19 11:04:26 -04:00
committed by GitHub
parent a141d3cde4
commit f4f4511cc7
57 changed files with 1089 additions and 1640 deletions

View File

@@ -10,7 +10,7 @@ import {setLoggingLevel} from 'common/log';
import {handleConfigUpdate} from 'main/app/config';
import {handleMainWindowIsShown} from 'main/app/intercom';
import WindowManager from 'main/windows/windowManager';
import MainWindow from 'main/windows/mainWindow';
import AutoLauncher from 'main/AutoLauncher';
jest.mock('electron', () => ({
@@ -47,8 +47,7 @@ jest.mock('main/views/viewManager', () => ({
reloadConfiguration: jest.fn(),
}));
jest.mock('main/views/loadingScreen', () => ({}));
jest.mock('main/windows/windowManager', () => ({
handleUpdateConfig: jest.fn(),
jest.mock('main/windows/mainWindow', () => ({
sendToRenderer: jest.fn(),
}));
@@ -65,11 +64,11 @@ describe('main/app/config', () => {
it('should reload renderer config only when app is ready', () => {
handleConfigUpdate({});
expect(WindowManager.sendToRenderer).not.toBeCalled();
expect(MainWindow.sendToRenderer).not.toBeCalled();
app.isReady.mockReturnValue(true);
handleConfigUpdate({});
expect(WindowManager.sendToRenderer).toBeCalledWith(RELOAD_CONFIGURATION);
expect(MainWindow.sendToRenderer).toBeCalledWith(RELOAD_CONFIGURATION);
});
it('should set download path if applicable', () => {