diff --git a/src/chrome/JSEmulatorLauncherSheet.tsx b/src/chrome/JSEmulatorLauncherSheet.tsx index 9cca353e6..c266fc420 100644 --- a/src/chrome/JSEmulatorLauncherSheet.tsx +++ b/src/chrome/JSEmulatorLauncherSheet.tsx @@ -21,6 +21,8 @@ import React, {Component} from 'react'; import {connect} from 'react-redux'; import {State as Store} from '../reducers'; import {launchJsEmulator} from '../utils/js-client/serverUtils'; +import {updateSettings, Action} from '../reducers/settings'; +import {Settings} from '../reducers/settings'; const Container = styled(FlexColumn)({ padding: 20, @@ -48,22 +50,33 @@ type OwnProps = { onHide: () => void; }; -type StateFromProps = {}; +type StateFromProps = { + settings: Settings; +}; -type DispatchFromProps = {}; +type DispatchFromProps = { + updateSettings: (settings: Settings) => Action; +}; type State = { url: string; - width: number; height: number; + width: number; }; type Props = OwnProps & StateFromProps & DispatchFromProps; class JSEmulatorLauncherSheet extends Component { - state: State = { - url: 'http://localhost:8888', - width: 800, - height: 600, + state: State = {...this.props.settings.jsApps.webAppLauncher}; + + applyChanges = async () => { + launchJsEmulator(this.state.url, this.state.height, this.state.width); + this.props.updateSettings({ + ...this.props.settings, + jsApps: { + webAppLauncher: {...this.state}, + }, + }); + this.props.onHide(); }; onUrlChange = (e: React.ChangeEvent) => { @@ -96,18 +109,7 @@ class JSEmulatorLauncherSheet extends Component { - @@ -117,6 +119,8 @@ class JSEmulatorLauncherSheet extends Component { } export default connect( - () => ({}), - {}, + ({settingsState}) => ({ + settings: settingsState, + }), + {updateSettings}, )(JSEmulatorLauncherSheet); diff --git a/src/reducers/settings.tsx b/src/reducers/settings.tsx index 2b1517e40..9f9833d21 100644 --- a/src/reducers/settings.tsx +++ b/src/reducers/settings.tsx @@ -24,6 +24,13 @@ export type Settings = { * of Flipper. */ enablePrefetching: Tristate; + jsApps: { + webAppLauncher: { + url: string; + height: number; + width: number; + }; + }; }; export type Action = @@ -37,6 +44,13 @@ const initialState: Settings = { androidHome: '/opt/android_sdk', enableAndroid: true, enablePrefetching: Tristate.Unset, + jsApps: { + webAppLauncher: { + url: 'http://localhost:8888', + height: 600, + width: 800, + }, + }, }; export default function reducer(