Add restartFlipper utility
Summary: Centralizes the restart logic. And adds ability for it to work in dev mode as well. Reviewed By: passy Differential Revision: D18008197 fbshipit-source-id: b76ac7935d5859dfdbb8cf593462f8ac02348181
This commit is contained in:
committed by
Facebook Github Bot
parent
9775e5b0e0
commit
c63f145ffb
@@ -35,6 +35,7 @@ import {promisify} from 'util';
|
||||
import {homedir} from 'os';
|
||||
import {PluginManager as PM} from 'live-plugin-manager';
|
||||
import {reportPlatformFailures, reportUsage} from '../utils/metrics';
|
||||
import restartFlipper from '../utils/restartFlipper';
|
||||
|
||||
const PLUGIN_DIR = path.join(homedir(), '.flipper', 'thirdparty');
|
||||
const ALGOLIA_APPLICATION_ID = 'OFCNCOG2CU';
|
||||
@@ -121,8 +122,7 @@ const PluginInstaller = function props(props: Props) {
|
||||
props.getInstalledPlugins,
|
||||
);
|
||||
const restartApp = useCallback(() => {
|
||||
remote.app.relaunch();
|
||||
remote.app.exit();
|
||||
restartFlipper();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
||||
@@ -16,8 +16,8 @@ import {Settings} from '../reducers/settings';
|
||||
import {flush} from '../utils/persistor';
|
||||
import ToggledSection from './settings/ToggledSection';
|
||||
import {FilePathConfigField, ConfigText} from './settings/configFields';
|
||||
import {remote} from 'electron';
|
||||
import isEqual from 'lodash.isequal';
|
||||
import restartFlipper from '../utils/restartFlipper';
|
||||
|
||||
const Container = styled(FlexColumn)({
|
||||
padding: 20,
|
||||
@@ -58,8 +58,7 @@ class SettingsSheet extends Component<Props, State> {
|
||||
this.props.updateSettings(this.state.updatedSettings);
|
||||
this.props.onHide();
|
||||
flush().then(() => {
|
||||
remote.app.relaunch();
|
||||
remote.app.exit();
|
||||
restartFlipper();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
24
src/utils/restartFlipper.tsx
Normal file
24
src/utils/restartFlipper.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {remote} from 'electron';
|
||||
import isProduction from './isProduction';
|
||||
|
||||
export default function restart() {
|
||||
if (isProduction()) {
|
||||
remote.app.relaunch();
|
||||
remote.app.exit();
|
||||
} else {
|
||||
// Relaunching the process doesn't work in dev mode
|
||||
// because it just launches an empty electron shell.
|
||||
// Instead, approximate it by doing a refresh.
|
||||
// Should be roughly equivalent but there may be some differences.
|
||||
remote.getCurrentWindow().reload();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user