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() {
const config = await getConfig()
console.log(config.last_ip)
console.log(config.last_port)
this.setState({
grasscutterEnabled: config.toggle_grasscutter,
buttonLabel: await translate('main.launch_button'),
@@ -152,10 +155,10 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
{
this.state.grasscutterEnabled && (
<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={{
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} />
</div>
)

View File

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