From d30409028a7f6fdc2a17380be0828e78fc4a954e Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Fri, 13 May 2022 22:25:55 -0700 Subject: [PATCH] save last ip and port --- src/ui/components/ServerLaunchSection.tsx | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/ui/components/ServerLaunchSection.tsx b/src/ui/components/ServerLaunchSection.tsx index 22f7bc1..4a8cdaf 100644 --- a/src/ui/components/ServerLaunchSection.tsx +++ b/src/ui/components/ServerLaunchSection.tsx @@ -1,7 +1,7 @@ import React from 'react' import Checkbox from './common/Checkbox' import BigButton from './common/BigButton' -import { getConfig, saveConfig } from '../../utils/configuration' +import { getConfig, saveConfig, setConfigOption } from '../../utils/configuration' import { translate } from '../../utils/language' import { invoke } from '@tauri-apps/api/tauri' @@ -40,6 +40,8 @@ export default class ServerLaunchSection extends React.Component this.toggleGrasscutter = this.toggleGrasscutter.bind(this) this.playGame = this.playGame.bind(this) + this.setIp = this.setIp.bind(this) + this.setPort = this.setPort.bind(this) } async componentDidMount() { @@ -49,6 +51,8 @@ export default class ServerLaunchSection extends React.Component grasscutterEnabled: config.toggle_grasscutter, buttonLabel: await translate('main.launch_button'), checkboxLabel: await translate('main.gc_enable'), + ip: config.last_ip || '', + port: config.last_port || '', ipPlaceholder: await translate('main.ip_placeholder'), portPlaceholder: await translate('main.port_placeholder') }) @@ -73,7 +77,14 @@ export default class ServerLaunchSection extends React.Component if (!config.game_path) return // Connect to proxy - if (config.toggle_grasscutter) await invoke('connect', { port: 8365 }) + if (config.toggle_grasscutter) { + // Save last connected server and port + await setConfigOption('last_ip', this.state.ip) + await setConfigOption('last_port', this.state.port) + + // Connect to proxy + await invoke('connect', { port: 8365 }) + } // Launch the program await invoke('run_program', { path: config.game_path }) @@ -111,7 +122,6 @@ export default class ServerLaunchSection extends React.Component }) } - render() { return (
@@ -120,8 +130,8 @@ export default class ServerLaunchSection extends React.Component
- , - + , +