OS X changes

This commit is contained in:
Scott E. Graves
2018-11-08 12:47:52 -06:00
parent f7574c0815
commit acfeb4a9a2
5 changed files with 97 additions and 99 deletions

View File

@@ -171,78 +171,27 @@ class App extends Component {
};
handleAutoMountChanged = (storageType, e) => {
let sia = {
...this.state.Sia
const state = {
...this.state[storageType],
AutoMount: e.target.checked,
};
let siaPrime = {
...this.state.SiaPrime
};
let hyperspace = {
...this.state.Hyperspace
};
if (storageType === 'Hyperspace') {
hyperspace.AutoMount = e.target.checked;
this.setState({
Hyperspace: hyperspace,
}, ()=> {
this.saveState(this.state.Release, this.state.Version, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
});
} else if (storageType === 'Sia') {
sia.AutoMount = e.target.checked;
this.setState({
Sia: sia,
}, ()=> {
this.saveState(this.state.Release, this.state.Version, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
});
} else if (storageType === 'SiaPrime') {
siaPrime.AutoMount = e.target.checked;
this.setState({
SiaPrime: siaPrime,
}, ()=> {
this.saveState(this.state.Release, this.state.Version, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
});
}
this.setState({
[storageType]: state,
}, ()=> {
this.saveState(this.state.Release, this.state.Version, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
});
};
handleAutoRestartChanged = (storageType, e) => {
let sia = {
...this.state.Sia
const state = {
...this.state[storageType],
AutoRestart: e.target.checked,
};
let siaPrime = {
...this.state.SiaPrime
};
let hyperspace = {
...this.state.Hyperspace
};
if (storageType === 'Hyperspace') {
hyperspace.AutoRestart = e.target.checked;
this.setState({
Hyperspace: hyperspace,
}, ()=> {
this.saveState(this.state.Release, this.state.Version, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
});
} else if (storageType === 'Sia') {
sia.AutoRestart = e.target.checked;
this.setState({
Sia: sia,
}, ()=> {
this.saveState(this.state.Release, this.state.Version, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
});
} else if (storageType === 'SiaPrime') {
siaPrime.AutoRestart = e.target.checked;
this.setState({
SiaPrime: siaPrime,
}, ()=> {
this.saveState(this.state.Release, this.state.Version, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
});
}
this.setState({
[storageType]: state,
}, ()=> {
this.saveState(this.state.Release, this.state.Version, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
});
};
handleConfigClicked = (storageType) => {
@@ -281,30 +230,21 @@ class App extends Component {
...this.state[storageType],
MountLocation: location,
};
const hyperspace = (storageType === 'Hyperspace') ? state : {
...this.state.Hyperspace,
};
const sia = storageType === 'Sia' ? state : {
...this.state.Sia,
};
const siaPrime = storageType === 'SiaPrime' ? state : {
...this.state.SiaPrime,
};
this.saveState(this.state.Release, this.state.Version, sia, hyperspace, siaPrime);
this.setState({
[storageType]: state,
}, ()=> {
this.saveState(this.state.Release, this.state.Version, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
});
};
handleReleaseChanged = (e) => {
const val = parseInt(e.target.value, 10);
const versionIndex = this.state.VersionLookup[this.state.ReleaseTypes[val]].length - 1;
this.saveState(val, versionIndex, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
this.setState({
Release: val,
Version: versionIndex
}, ()=> {
this.saveState(this.state.Release, this.state.Version, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
this.checkVersionInstalled( );
});
};
@@ -346,11 +286,10 @@ class App extends Component {
};
handleVersionChanged = (e) => {
const val = parseInt(e.target.value, 10);
this.saveState(this.state.Release, val, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
this.setState({
Version: val
Version: parseInt(e.target.value, 10),
}, ()=> {
this.saveState(this.state.Release, this.state.Version, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
this.checkVersionInstalled( );
});
};
@@ -415,6 +354,7 @@ class App extends Component {
if (arg.data.Success) {
ipcRenderer.send(Constants.IPC_Install_Dependency, {
Source: arg.data.Destination,
URL: arg.data.URL,
});
}
@@ -579,10 +519,14 @@ class App extends Component {
};
onInstallDependencyReply = (event, arg) => {
ipcRenderer.send(Constants.IPC_Delete_File, {
FilePath: arg.data.Source,
});
this.checkVersionInstalled( );
if (arg.data.Success && arg.data.Source.toLowerCase().endsWith('.dmg')) {
this.waitForDependencyInstall(arg.data.URL);
} else {
ipcRenderer.send(Constants.IPC_Delete_File, {
FilePath: arg.data.Source,
});
this.checkVersionInstalled();
}
};
onInstallUpgradeReply = (event, arg) => {
@@ -627,6 +571,22 @@ class App extends Component {
}
};
waitForDependencyInstall = (url) => {
const dep = this.state.MissingDependencies.find(d => {
return d.download === url;
});
const i = setInterval(()=> {
const ret = ipcRenderer.sendSync(Constants.IPC_Check_Dependency_Installed, {
File: dep.file,
});
if (ret.data.Exists || !ret.data.Success) {
clearInterval(i);
this.checkVersionInstalled();
}
}, 3000);
};
render() {
const selectedVersion = (this.state.Version === -1) ?
'unavailable' :