diff --git a/desktop/app/src/dispatcher/__tests__/plugins.node.tsx b/desktop/app/src/dispatcher/__tests__/plugins.node.tsx index 01329754c..95fc9c57b 100644 --- a/desktop/app/src/dispatcher/__tests__/plugins.node.tsx +++ b/desktop/app/src/dispatcher/__tests__/plugins.node.tsx @@ -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,24 +81,29 @@ 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 disabled = checkDisabled([]); + const orig = process.env.CONFIG; + try { + process.env.CONFIG = JSON.stringify(config); + const disabled = checkDisabled([]); - expect( - disabled({ - ...sampleBundledPluginDetails, - name: 'other Name', - version: '1.0.0', - }), - ).toBeTruthy(); + expect( + disabled({ + ...sampleBundledPluginDetails, + name: 'other Name', + version: '1.0.0', + }), + ).toBeTruthy(); - expect( - disabled({ - ...sampleBundledPluginDetails, - name: disabledPlugin, - version: '1.0.0', - }), - ).toBeFalsy(); + expect( + disabled({ + ...sampleBundledPluginDetails, + name: disabledPlugin, + version: '1.0.0', + }), + ).toBeFalsy(); + } finally { + process.env.CONFIG = orig; + } }); test('checkGK for plugin without GK', () => { diff --git a/desktop/app/src/dispatcher/application.tsx b/desktop/app/src/dispatcher/application.tsx index 9f9f04bba..f860e7c2a 100644 --- a/desktop/app/src/dispatcher/application.tsx +++ b/desktop/app/src/dispatcher/application.tsx @@ -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()},