mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-14 16:14:48 +01:00
fix button text not updating
This commit is contained in:
@@ -62,6 +62,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
// Remove jar from path
|
// Remove jar from path
|
||||||
const path = config.grasscutter_path.replace(/\\/g, '/')
|
const path = config.grasscutter_path.replace(/\\/g, '/')
|
||||||
const folderPath = path.substring(0, path.lastIndexOf('/'))
|
const folderPath = path.substring(0, path.lastIndexOf('/'))
|
||||||
|
const encEnabled = await server.encryptionEnabled(folderPath + '/config.json')
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
game_install_path: config.game_install_path || '',
|
game_install_path: config.game_install_path || '',
|
||||||
@@ -73,7 +74,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
bg_url_or_path: config.customBackground || '',
|
bg_url_or_path: config.customBackground || '',
|
||||||
themes: (await getThemeList()).map(t => t.name),
|
themes: (await getThemeList()).map(t => t.name),
|
||||||
theme: config.theme || 'default',
|
theme: config.theme || 'default',
|
||||||
encryption: await server.encryptionEnabled(folderPath + '/config.json') || false
|
encryption: await translate(encEnabled ? 'options.enabled' : 'options.disabled')
|
||||||
})
|
})
|
||||||
|
|
||||||
this.forceUpdate()
|
this.forceUpdate()
|
||||||
@@ -162,7 +163,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
await server.toggleEncryption(folderPath + '/config.json')
|
await server.toggleEncryption(folderPath + '/config.json')
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
encryption: !this.state.encryption
|
encryption: await translate(await server.encryptionEnabled(folderPath + '/config.json') ? 'options.enabled' : 'options.disabled')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,9 +193,7 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
<div className='OptionValue'>
|
<div className='OptionValue'>
|
||||||
<BigButton onClick={this.toggleEncryption} id="toggleEnc">
|
<BigButton onClick={this.toggleEncryption} id="toggleEnc">
|
||||||
{
|
{
|
||||||
this.state.encryption ?
|
this.state.encryption
|
||||||
<Tr text="options.enabled" /> :
|
|
||||||
<Tr text="options.disabled" />
|
|
||||||
}
|
}
|
||||||
</BigButton>
|
</BigButton>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user