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

@@ -12,9 +12,10 @@ import {
CALLS_PLUGIN_ID,
} from 'common/utils/constants';
import urlUtils from 'common/utils/url';
import {switchServer} from 'main/app/servers';
import MainWindow from 'main/windows/mainWindow';
import ViewManager from 'main/views/viewManager';
import WindowManager from 'main/windows/windowManager';
import {
resetScreensharePermissionsMacOS,
openScreensharePermissionsSettingsMacOS,
@@ -55,7 +56,7 @@ jest.mock('main/windows/mainWindow', () => ({
get: jest.fn(),
focus: jest.fn(),
}));
jest.mock('main/windows/windowManager', () => ({
jest.mock('main/app/servers', () => ({
switchServer: jest.fn(),
}));
jest.mock('main/views/viewManager', () => ({
@@ -797,7 +798,7 @@ describe('main/windows/callsWidgetWindow', () => {
it('should switch server', () => {
callsWidgetWindow.handleDesktopSourcesModalRequest();
expect(WindowManager.switchServer).toHaveBeenCalledWith('server-1');
expect(switchServer).toHaveBeenCalledWith('server-1');
});
});
@@ -864,7 +865,7 @@ describe('main/windows/callsWidgetWindow', () => {
it('should switch server', () => {
callsWidgetWindow.handleCallsWidgetChannelLinkClick();
expect(WindowManager.switchServer).toHaveBeenCalledWith('server-2');
expect(switchServer).toHaveBeenCalledWith('server-2');
});
});
@@ -890,7 +891,7 @@ describe('main/windows/callsWidgetWindow', () => {
it('should focus view and propagate error to main view', () => {
callsWidgetWindow.handleCallsError('', {err: 'client-error'});
expect(WindowManager.switchServer).toHaveBeenCalledWith('server-2');
expect(switchServer).toHaveBeenCalledWith('server-2');
expect(focus).toHaveBeenCalled();
expect(callsWidgetWindow.mainView.sendToRenderer).toHaveBeenCalledWith('calls-error', {err: 'client-error'});
});
@@ -918,7 +919,7 @@ describe('main/windows/callsWidgetWindow', () => {
it('should pass through the click link to browser history push', () => {
callsWidgetWindow.handleCallsLinkClick('', {link: '/other/subpath'});
expect(WindowManager.switchServer).toHaveBeenCalledWith('server-1');
expect(switchServer).toHaveBeenCalledWith('server-1');
expect(view.sendToRenderer).toBeCalledWith('browser-history-push', '/other/subpath');
});
});