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'; } from '../plugins';
import {BundledPluginDetails, InstalledPluginDetails} from 'flipper-plugin-lib'; import {BundledPluginDetails, InstalledPluginDetails} from 'flipper-plugin-lib';
import path from 'path'; 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 {createRootReducer, State} from '../../reducers/index';
import {getLogger} from 'flipper-common'; import {getLogger} from 'flipper-common';
import configureStore from 'redux-mock-store'; import configureStore from 'redux-mock-store';
@@ -84,7 +81,9 @@ test('getDynamicPlugins returns empty array on errors', async () => {
test('checkDisabled', () => { test('checkDisabled', () => {
const disabledPlugin = 'pluginName'; const disabledPlugin = 'pluginName';
const config = {disabledPlugins: [disabledPlugin]}; 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([]); const disabled = checkDisabled([]);
expect( expect(
@@ -102,6 +101,9 @@ test('checkDisabled', () => {
version: '1.0.0', version: '1.0.0',
}), }),
).toBeFalsy(); ).toBeFalsy();
} finally {
process.env.CONFIG = orig;
}
}); });
test('checkGK for plugin without GK', () => { test('checkGK for plugin without GK', () => {

View File

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