From 7cfd41f9b0947044dbb8c7894e240a6ca282af0b Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Sun, 29 May 2022 18:25:26 -0700 Subject: [PATCH] proper last connection autofill --- src/ui/components/ServerLaunchSection.tsx | 7 +++++-- src/ui/components/common/TextInput.tsx | 9 +++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ui/components/ServerLaunchSection.tsx b/src/ui/components/ServerLaunchSection.tsx index 21fd547..af392db 100644 --- a/src/ui/components/ServerLaunchSection.tsx +++ b/src/ui/components/ServerLaunchSection.tsx @@ -51,6 +51,9 @@ export default class ServerLaunchSection extends React.Component 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 { this.state.grasscutterEnabled && (
- + + }} id="port" key="port" placeholder={this.state.portPlaceholder} onChange={this.setPort} initalValue={this.state.port} />
) diff --git a/src/ui/components/common/TextInput.tsx b/src/ui/components/common/TextInput.tsx index c72c604..2d8dbe2 100644 --- a/src/ui/components/common/TextInput.tsx +++ b/src/ui/components/common/TextInput.tsx @@ -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 { return { value: props.value || '' } } + async componentDidMount() { + if (this.props.initalValue) { + this.setState({ + value: this.props.initalValue + }) + } + } + render() { return (