mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-15 00:24:45 +01:00
fix download button states
This commit is contained in:
@@ -24,6 +24,7 @@ export default class BigButton extends React.Component<IProps, IState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static getDerivedStateFromProps(props: IProps, state: IState) {
|
static getDerivedStateFromProps(props: IProps, state: IState) {
|
||||||
|
console.log(props)
|
||||||
return {
|
return {
|
||||||
disabled: props.disabled
|
disabled: props.disabled
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ export default class Downloads extends React.Component<IProps, IState> {
|
|||||||
this.downloadGrasscutterStable = this.downloadGrasscutterStable.bind(this)
|
this.downloadGrasscutterStable = this.downloadGrasscutterStable.bind(this)
|
||||||
this.downloadGrasscutterLatest = this.downloadGrasscutterLatest.bind(this)
|
this.downloadGrasscutterLatest = this.downloadGrasscutterLatest.bind(this)
|
||||||
this.downloadResources = this.downloadResources.bind(this)
|
this.downloadResources = this.downloadResources.bind(this)
|
||||||
|
this.disableButtons = this.disableButtons.bind(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGrasscutterFolder() {
|
async getGrasscutterFolder() {
|
||||||
@@ -47,28 +48,36 @@ export default class Downloads extends React.Component<IProps, IState> {
|
|||||||
folderPath = path.substring(0, path.lastIndexOf('\\'))
|
folderPath = path.substring(0, path.lastIndexOf('\\'))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set states since we know we are downloading something if this is called
|
|
||||||
this.setState({
|
|
||||||
grasscutter_downloading: this.props.downloadManager.downloadingJar(),
|
|
||||||
resources_downloading: this.props.downloadManager.downloadingResources()
|
|
||||||
})
|
|
||||||
|
|
||||||
return folderPath
|
return folderPath
|
||||||
}
|
}
|
||||||
|
|
||||||
async downloadGrasscutterStable() {
|
async downloadGrasscutterStable() {
|
||||||
const folder = await this.getGrasscutterFolder()
|
const folder = await this.getGrasscutterFolder()
|
||||||
this.props.downloadManager.addDownload(STABLE_DOWNLOAD, folder + '\\grasscutter.jar')
|
this.props.downloadManager.addDownload(STABLE_DOWNLOAD, folder + '\\grasscutter.jar')
|
||||||
|
|
||||||
|
this.disableButtons()
|
||||||
}
|
}
|
||||||
|
|
||||||
async downloadGrasscutterLatest() {
|
async downloadGrasscutterLatest() {
|
||||||
const folder = await this.getGrasscutterFolder()
|
const folder = await this.getGrasscutterFolder()
|
||||||
this.props.downloadManager.addDownload(DEV_DOWNLOAD, folder + '\\grasscutter.jar')
|
this.props.downloadManager.addDownload(DEV_DOWNLOAD, folder + '\\grasscutter.jar')
|
||||||
|
|
||||||
|
this.disableButtons()
|
||||||
}
|
}
|
||||||
|
|
||||||
async downloadResources() {
|
async downloadResources() {
|
||||||
const folder = await this.getGrasscutterFolder()
|
const folder = await this.getGrasscutterFolder()
|
||||||
this.props.downloadManager.addDownload(RESOURCES_DOWNLOAD, folder + '\\resources.zip')
|
this.props.downloadManager.addDownload(RESOURCES_DOWNLOAD, folder + '\\resources.zip')
|
||||||
|
|
||||||
|
this.disableButtons()
|
||||||
|
}
|
||||||
|
|
||||||
|
disableButtons() {
|
||||||
|
// Set states since we know we are downloading something if this is called
|
||||||
|
this.setState({
|
||||||
|
grasscutter_downloading: this.props.downloadManager.downloadingJar(),
|
||||||
|
resources_downloading: this.props.downloadManager.downloadingResources()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|||||||
Reference in New Issue
Block a user