proper last connection autofill

This commit is contained in:
SpikeHD
2022-05-29 18:25:26 -07:00
parent c15e82b30a
commit 7cfd41f9b0
2 changed files with 14 additions and 2 deletions

View File

@@ -51,6 +51,9 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
async componentDidMount() { async componentDidMount() {
const config = await getConfig() const config = await getConfig()
console.log(config.last_ip)
console.log(config.last_port)
this.setState({ this.setState({
grasscutterEnabled: config.toggle_grasscutter, grasscutterEnabled: config.toggle_grasscutter,
buttonLabel: await translate('main.launch_button'), buttonLabel: await translate('main.launch_button'),
@@ -152,10 +155,10 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
{ {
this.state.grasscutterEnabled && ( this.state.grasscutterEnabled && (
<div className="ServerConfig"> <div className="ServerConfig">
<TextInput id="ip" key="ip" placeholder={this.state.ipPlaceholder} onChange={this.setIp} /> <TextInput id="ip" key="ip" placeholder={this.state.ipPlaceholder} onChange={this.setIp} initalValue={this.state.ip} />
<TextInput style={{ <TextInput style={{
width: '10%', width: '10%',
}} id="port" key="port" placeholder={this.state.portPlaceholder} onChange={this.setPort}/> }} id="port" key="port" placeholder={this.state.portPlaceholder} onChange={this.setPort} initalValue={this.state.port} />
<HelpButton contents={this.state.portHelpText} /> <HelpButton contents={this.state.portHelpText} />
</div> </div>
) )

View File

@@ -5,6 +5,7 @@ import Close from '../../../resources/icons/close.svg'
interface IProps { interface IProps {
value?: string; value?: string;
initalValue?: string;
placeholder?: string; placeholder?: string;
onChange?: (value: string) => void; onChange?: (value: string) => void;
readOnly?: boolean; readOnly?: boolean;
@@ -38,6 +39,14 @@ export default class TextInput extends React.Component<IProps, IState> {
return { value: props.value || '' } return { value: props.value || '' }
} }
async componentDidMount() {
if (this.props.initalValue) {
this.setState({
value: this.props.initalValue
})
}
}
render() { render() {
return ( return (
<div className="TextInputWrapper" style={this.props.style || {}}> <div className="TextInputWrapper" style={this.props.style || {}}>