mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-14 16:14:48 +01:00
proper last connection autofill
This commit is contained in:
@@ -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>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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 || {}}>
|
||||||
|
|||||||
Reference in New Issue
Block a user