Factored out ipcRender.send

Summary: Delegate sending events over IPC from the render process to the main process over the RenderHost interface. This basically removes all our direct usages of `ipcRenderer`.

Reviewed By: timur-valiev, aigoncharov

Differential Revision: D31828580

fbshipit-source-id: 9c1333ae55620d36c2af70aa7abc5403c2f4907c
This commit is contained in:
Michel Weststrate
2021-10-22 09:20:14 -07:00
committed by Facebook GitHub Bot
parent ecf2e32722
commit 75df79a248
4 changed files with 34 additions and 18 deletions

View File

@@ -57,7 +57,7 @@ import {
GK as flipperCommonGK,
} from 'flipper-common';
import {internGraphPOSTAPIRequest} from './fb-stubs/user';
import {setRenderHostInstance} from './RenderHost';
import {getRenderHostInstance, setRenderHostInstance} from './RenderHost';
import {clipboard} from 'electron';
if (process.env.NODE_ENV === 'development' && os.platform() === 'darwin') {
@@ -249,7 +249,7 @@ function init() {
(
document.getElementById('flipper-theme-import') as HTMLLinkElement
).href = `themes/${result.shouldUseDarkMode ? 'dark' : 'light'}.css`;
ipcRenderer.send('setTheme', result.theme);
getRenderHostInstance().sendIpcEvent('setTheme', result.theme);
},
);
}
@@ -302,5 +302,8 @@ function initializeFlipperForElectron() {
callback(...(args as any));
});
},
sendIpcEvent(event, ...args: any[]) {
ipcRenderer.send(event, ...args);
},
});
}