Redux changes and refactoring

This commit is contained in:
Scott E. Graves
2019-06-05 17:18:48 -05:00
parent fc48c9c0db
commit 539238efb7
10 changed files with 163 additions and 160 deletions

View File

@@ -42,14 +42,12 @@ class App extends IPCContainer {
this.setRequestHandler(Constants.IPC_Install_Dependency_Reply, this.onInstallDependencyReply);
this.setRequestHandler(Constants.IPC_Install_Upgrade_Reply, this.onInstallUpgradeReply);
this.sendRequest(Constants.IPC_Get_State, Constants.DATA_LOCATIONS[this.props.platform]);
this.sendRequest(Constants.IPC_Get_State);
Scheduler.scheduleJob('23 11 * * *', this.updateCheckScheduledJob);
}
state = {
AllowDownload: false,
AutoMountProcessed: false,
ConfigStorageType: null,
DisplayError: false,
DisplayMainContent: false,
Error: null,
@@ -106,7 +104,6 @@ class App extends IPCContainer {
this.sendRequest(Constants.IPC_Check_Installed, {
Dependencies: dependencies,
Directory: Constants.DATA_LOCATIONS[this.props.platform],
Version: selectedVersion,
});
}
@@ -137,7 +134,6 @@ class App extends IPCContainer {
if (data.Success) {
const selectedVersion = this.getSelectedVersion();
this.sendRequest(Constants.IPC_Extract_Release, {
Directory: Constants.DATA_LOCATIONS[this.props.platform],
Source: data.Destination,
Version: selectedVersion,
});
@@ -157,7 +153,7 @@ class App extends IPCContainer {
};
grabReleases = () => {
if (this.props.platform !== 'unknown') {
if (this.props.Platform !== 'unknown') {
this.sendRequest(Constants.IPC_Grab_Releases);
this.sendRequest(Constants.IPC_Grab_UI_Releases);
}
@@ -187,18 +183,6 @@ class App extends IPCContainer {
});
};
handleConfigClicked = (storageType) => {
this.setState({
ConfigStorageType: storageType,
})
};
handleConfigClosed = () => {
this.setState({
ConfigStorageType: null,
});
};
handleDependencyDownload = (url) => {
this.setState({
DownloadActive: true,
@@ -206,7 +190,6 @@ class App extends IPCContainer {
DownloadName: this.extractFileNameFromURL(url),
}, ()=> {
this.sendRequest(Constants.IPC_Download_File, {
Directory: Constants.DATA_LOCATIONS[this.props.platform],
Filename: this.state.DownloadName,
URL: url,
});
@@ -246,7 +229,6 @@ class App extends IPCContainer {
DownloadName: fileName,
}, () => {
this.sendRequest(Constants.IPC_Download_File, {
Directory: Constants.DATA_LOCATIONS[this.props.platform],
Filename: this.state.DownloadName,
URL: this.state.LocationsLookup[selectedVersion].urls[0],
});
@@ -261,8 +243,7 @@ class App extends IPCContainer {
}, ()=> {
const url = this.state.UpgradeData.urls[0];
this.sendRequest(Constants.IPC_Download_File, {
Directory: Constants.DATA_LOCATIONS[this.props.platform],
Filename: this.props.platform === 'win32' ? 'upgrade.exe' : this.extractFileNameFromURL(url),
Filename: this.props.Platform === 'win32' ? 'upgrade.exe' : this.extractFileNameFromURL(url),
URL: url,
});
});
@@ -295,8 +276,8 @@ class App extends IPCContainer {
installUpgrade = data => {
if (data.Success) {
const sha256 = this.state.LocationsLookup[this.props.platform][this.state.VersionLookup[this.props.platform][0]].sha256;
const signature = this.state.LocationsLookup[this.props.platform][this.state.VersionLookup[this.props.platform][0]].sig;
const sha256 = this.state.LocationsLookup[this.props.Platform][this.state.VersionLookup[this.props.Platform][0]].sha256;
const signature = this.state.LocationsLookup[this.props.Platform][this.state.VersionLookup[this.props.Platform][0]].sig;
this.sendRequest(Constants.IPC_Install_Upgrade, {
Sha256: sha256,
Signature: signature,
@@ -313,10 +294,6 @@ class App extends IPCContainer {
}
};
notifyAutoMountProcessed = () => {
this.setState({AutoMountProcessed: true});
};
onCheckInstalledReply = (event, arg) => {
const action = () => {
const installedVersion = arg.data.Success && arg.data.Exists ? arg.data.Version : 'none';
@@ -431,13 +408,13 @@ class App extends IPCContainer {
.get(Constants.RELEASES_URL)
.then(response => {
const versionLookup = {
Alpha: response.data.Versions.Alpha[this.props.platform],
Beta: response.data.Versions.Beta[this.props.platform],
RC: response.data.Versions.RC[this.props.platform],
Release: response.data.Versions.Release[this.props.platform],
Alpha: response.data.Versions.Alpha[this.props.Platform],
Beta: response.data.Versions.Beta[this.props.Platform],
RC: response.data.Versions.RC[this.props.Platform],
Release: response.data.Versions.Release[this.props.Platform],
};
const locationsLookup = {
...response.data.Locations[this.props.platform],
...response.data.Locations[this.props.Platform],
};
window.localStorage.setItem('releases', JSON.stringify({
@@ -466,13 +443,13 @@ class App extends IPCContainer {
.then(response => {
const data = response.data;
if (data.Versions &&
data.Versions[this.props.platform] &&
(data.Versions[this.props.platform].length > 0) &&
(data.Versions[this.props.platform][0] !== this.props.version)) {
data.Versions[this.props.Platform] &&
(data.Versions[this.props.Platform].length > 0) &&
(data.Versions[this.props.Platform][0] !== this.props.version)) {
this.setState({
UpgradeAvailable: true,
UpgradeDismissed: false,
UpgradeData: data.Locations[this.props.platform][data.Versions[this.props.platform][0]],
UpgradeData: data.Locations[this.props.Platform][data.Versions[this.props.Platform][0]],
});
}
}).catch(() => {
@@ -529,7 +506,6 @@ class App extends IPCContainer {
}
this.sendRequest(Constants.IPC_Save_State, {
Directory: Constants.DATA_LOCATIONS[this.props.platform],
State: state
});
};
@@ -546,7 +522,7 @@ class App extends IPCContainer {
};
updateCheckScheduledJob = () => {
if (this.props.platform !== 'unknown') {
if (this.props.Platform !== 'unknown') {
this.grabReleases();
}
};
@@ -593,7 +569,7 @@ class App extends IPCContainer {
this.state.LocationsLookup[selectedVersion].no_console_supported;
const showConfig = !missingDependencies &&
this.state.ConfigStorageType &&
this.props.DisplayConfiguration &&
allowConfig;
const showUpgrade = this.state.UpgradeAvailable &&
@@ -621,10 +597,7 @@ class App extends IPCContainer {
if (showConfig) {
configDisplay = (
<Modal>
<Configuration closed={this.handleConfigClosed}
directory={Constants.DATA_LOCATIONS[this.props.platform]}
errorHandler={this.setErrorState}
storageType={this.state.ConfigStorageType}
<Configuration errorHandler={this.setErrorState}
version={selectedVersion} />
</Modal>
);
@@ -695,14 +668,9 @@ class App extends IPCContainer {
allowSiaPrime={allowSiaPrime}
noConsoleSupported={noConsoleSupported}
autoMountChanged={this.handleAutoMountChanged}
autoMountProcessed={this.notifyAutoMountProcessed}
autoRestartChanged={this.handleAutoRestartChanged}
changed={this.handleMountLocationChanged}
configClicked={this.handleConfigClicked}
directory={Constants.DATA_LOCATIONS[this.props.platform]}
errorHandler={this.setErrorState}
platform={this.props.platform}
processAutoMount={!this.state.AutoMountProcessed}
version={this.state.InstalledVersion}/>
</div>
));
@@ -750,9 +718,11 @@ class App extends IPCContainer {
}
}
const mapStateToProps = state =>{
const mapStateToProps = state => {
return {
MountsBusy: state.mounts.MountsBusy
DisplayConfiguration: state.mounts.DisplayConfiguration,
MountsBusy: state.mounts.MountsBusy,
Platform: state.common.Platform,
};
};