From 7ce631483a27a4fbc3ce65eb6693043ccdcd1955 Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Sat, 14 May 2022 00:49:33 -0700 Subject: [PATCH] fix download button states --- src/ui/components/common/BigButton.tsx | 1 + src/ui/components/menu/Downloads.tsx | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/ui/components/common/BigButton.tsx b/src/ui/components/common/BigButton.tsx index 997e773..43b52a2 100644 --- a/src/ui/components/common/BigButton.tsx +++ b/src/ui/components/common/BigButton.tsx @@ -24,6 +24,7 @@ export default class BigButton extends React.Component { } static getDerivedStateFromProps(props: IProps, state: IState) { + console.log(props) return { disabled: props.disabled } diff --git a/src/ui/components/menu/Downloads.tsx b/src/ui/components/menu/Downloads.tsx index 6b05c87..f974dd5 100644 --- a/src/ui/components/menu/Downloads.tsx +++ b/src/ui/components/menu/Downloads.tsx @@ -35,6 +35,7 @@ export default class Downloads extends React.Component { this.downloadGrasscutterStable = this.downloadGrasscutterStable.bind(this) this.downloadGrasscutterLatest = this.downloadGrasscutterLatest.bind(this) this.downloadResources = this.downloadResources.bind(this) + this.disableButtons = this.disableButtons.bind(this) } async getGrasscutterFolder() { @@ -47,28 +48,36 @@ export default class Downloads extends React.Component { 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 } async downloadGrasscutterStable() { const folder = await this.getGrasscutterFolder() this.props.downloadManager.addDownload(STABLE_DOWNLOAD, folder + '\\grasscutter.jar') + + this.disableButtons() } async downloadGrasscutterLatest() { const folder = await this.getGrasscutterFolder() this.props.downloadManager.addDownload(DEV_DOWNLOAD, folder + '\\grasscutter.jar') + + this.disableButtons() } async downloadResources() { const folder = await this.getGrasscutterFolder() 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() {