Remove some Electron imports

Summary: Remove some Electron imports that weren't needed

Reviewed By: passy

Differential Revision: D31893756

fbshipit-source-id: 92edeb2e00a7c37e32365bb059d00d7c730a7a92
This commit is contained in:
Michel Weststrate
2021-10-25 06:10:42 -07:00
committed by Facebook GitHub Bot
parent ae726e7cac
commit 945f133593
2 changed files with 26 additions and 28 deletions

View File

@@ -18,9 +18,6 @@ import dispatcher, {
} from '../plugins';
import {BundledPluginDetails, InstalledPluginDetails} from 'flipper-plugin-lib';
import path from 'path';
// Allowed in a test.
// eslint-disable-next-line flipper/no-electron-remote-imports
import {remote} from 'electron';
import {createRootReducer, State} from '../../reducers/index';
import {getLogger} from 'flipper-common';
import configureStore from 'redux-mock-store';
@@ -84,7 +81,9 @@ test('getDynamicPlugins returns empty array on errors', async () => {
test('checkDisabled', () => {
const disabledPlugin = 'pluginName';
const config = {disabledPlugins: [disabledPlugin]};
remote.process.env.CONFIG = JSON.stringify(config);
const orig = process.env.CONFIG;
try {
process.env.CONFIG = JSON.stringify(config);
const disabled = checkDisabled([]);
expect(
@@ -102,6 +101,9 @@ test('checkDisabled', () => {
version: '1.0.0',
}),
).toBeFalsy();
} finally {
process.env.CONFIG = orig;
}
});
test('checkGK for plugin without GK', () => {

View File

@@ -7,9 +7,6 @@
* @format
*/
// Fine for app startup.
// eslint-disable-next-line flipper/no-electron-remote-imports
import {remote} from 'electron';
import {Store} from '../reducers/index';
import {Logger} from 'flipper-common';
import {
@@ -22,7 +19,6 @@ import {Dialog} from 'flipper-plugin';
import {getRenderHostInstance} from '../RenderHost';
export default (store: Store, logger: Logger) => {
const currentWindow = remote.getCurrentWindow();
const renderHost = getRenderHostInstance();
const onFocus = () => {
@@ -41,17 +37,17 @@ export default (store: Store, logger: Logger) => {
});
});
};
currentWindow.on('focus', onFocus);
currentWindow.on('blur', onBlur);
window.addEventListener('focus', onFocus);
window.addEventListener('blur', onBlur);
window.addEventListener('beforeunload', () => {
currentWindow.removeListener('focus', onFocus);
currentWindow.removeListener('blur', onBlur);
window.removeEventListener('focus', onFocus);
window.removeEventListener('blur', onBlur);
});
// windowIsFocussed is initialized in the store before the app is fully ready.
// So wait until everything is up and running and then check and set the isFocussed state.
window.addEventListener('flipper-store-ready', () => {
const isFocused = remote.getCurrentWindow().isFocused();
const isFocused = renderHost.hasFocus();
store.dispatch({
type: 'windowIsFocused',
payload: {isFocused: isFocused, time: Date.now()},