Redux changes and refactoring
This commit is contained in:
67
src/App.js
67
src/App.js
@@ -19,6 +19,7 @@ import {setProviderState} from './redux/actions/mount_actions';
|
||||
import {detectUIUpgrade, loadReleases, setActiveRelease, setDismissUIUpgrade, setReleaseUpgradeAvailable} from './redux/actions/release_version_actions';
|
||||
import {downloadItem, setAllowDownload} from './redux/actions/download_actions';
|
||||
import {installDependency, installRelease, installUpgrade} from './redux/actions/install_actions';
|
||||
import {notifyError} from './redux/actions/error_actions';
|
||||
|
||||
const Constants = require('./constants');
|
||||
const Scheduler = require('node-schedule');
|
||||
@@ -32,10 +33,6 @@ class App extends IPCContainer {
|
||||
}
|
||||
|
||||
state = {
|
||||
DisplayError: false,
|
||||
Error: null,
|
||||
ErrorAction: null,
|
||||
ErrorCritical: false,
|
||||
MissingDependencies: [],
|
||||
InstalledVersion: 'none',
|
||||
};
|
||||
@@ -56,21 +53,6 @@ class App extends IPCContainer {
|
||||
}
|
||||
};
|
||||
|
||||
closeErrorDisplay = () => {
|
||||
if (this.state.ErrorAction) {
|
||||
this.state.ErrorAction();
|
||||
}
|
||||
|
||||
if (this.state.ErrorCritical) {
|
||||
this.sendRequest(Constants.IPC_Shutdown);
|
||||
} else {
|
||||
this.setState({
|
||||
DisplayError: false,
|
||||
Error: null,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
this.sendRequest(Constants.IPC_Get_State);
|
||||
this.scheduledUpdateJob = Scheduler.scheduleJob('23 11 * * *', this.updateCheckScheduledJob);
|
||||
@@ -180,7 +162,7 @@ class App extends IPCContainer {
|
||||
if (arg.data.Success) {
|
||||
action();
|
||||
} else {
|
||||
this.setErrorState(arg.data.Error, action);
|
||||
this.props.notifyError(arg.data.Error, false, action);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -197,7 +179,7 @@ class App extends IPCContainer {
|
||||
this.installUpgrade(result);
|
||||
break;
|
||||
default:
|
||||
this.setErrorState('Unknown download type: ' + type, null, false);
|
||||
this.props.notifyError('Unknown download type: ' + type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -237,14 +219,16 @@ class App extends IPCContainer {
|
||||
|
||||
onInstallUpgradeComplete = (source, result) => {
|
||||
if (this.isMounted() && !result.Success) {
|
||||
this.setErrorState(result.Error, () => {
|
||||
// TODO Prompt to verify
|
||||
if (result.AllowSkipVerification) {
|
||||
this.installUpgrade( {
|
||||
SkipVerification: true,
|
||||
Source: source,
|
||||
Success: true,
|
||||
});
|
||||
this.props.notifyError(result.Error, false,() => {
|
||||
if (this.isMounted()) {
|
||||
// TODO Prompt to verify
|
||||
if (result.AllowSkipVerification) {
|
||||
this.installUpgrade({
|
||||
SkipVerification: true,
|
||||
Source: source,
|
||||
Success: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
@@ -267,17 +251,6 @@ class App extends IPCContainer {
|
||||
}
|
||||
};
|
||||
|
||||
setErrorState = (error, action, critical) => {
|
||||
this.setState({
|
||||
DisplayError: true,
|
||||
Error: error,
|
||||
ErrorAction: action,
|
||||
ErrorCritical: critical,
|
||||
}, () => {
|
||||
this.sendRequest(Constants.IPC_Show_Window);
|
||||
});
|
||||
};
|
||||
|
||||
updateCheckScheduledJob = () => {
|
||||
if (this.props.AppPlatform !== 'unknown') {
|
||||
this.detectUpgrades();
|
||||
@@ -333,7 +306,7 @@ class App extends IPCContainer {
|
||||
allowConfig;
|
||||
|
||||
const showUpgrade = this.props.UpgradeAvailable &&
|
||||
!this.state.DisplayError &&
|
||||
!this.props.DisplayError &&
|
||||
!showConfig &&
|
||||
!this.props.DownloadActive &&
|
||||
!this.props.UpgradeDismissed;
|
||||
@@ -343,12 +316,10 @@ class App extends IPCContainer {
|
||||
!this.props.DownloadActive;
|
||||
|
||||
let errorDisplay = null;
|
||||
if (this.state.DisplayError) {
|
||||
if (this.props.DisplayError) {
|
||||
errorDisplay = (
|
||||
<Modal critical>
|
||||
<ErrorDetails closed={this.closeErrorDisplay}
|
||||
critical={this.state.ErrorCritical}
|
||||
error={this.state.Error}/>
|
||||
<ErrorDetails/>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@@ -357,8 +328,7 @@ class App extends IPCContainer {
|
||||
if (showConfig) {
|
||||
configDisplay = (
|
||||
<Modal>
|
||||
<Configuration errorHandler={this.setErrorState}
|
||||
version={selectedVersion} />
|
||||
<Configuration version={selectedVersion} />
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@@ -412,7 +382,6 @@ class App extends IPCContainer {
|
||||
<MountItems allowConfig={allowConfig}
|
||||
allowSiaPrime={allowSiaPrime}
|
||||
noConsoleSupported={noConsoleSupported}
|
||||
errorHandler={this.setErrorState}
|
||||
version={this.state.InstalledVersion}/>
|
||||
</div>
|
||||
));
|
||||
@@ -466,6 +435,7 @@ const mapStateToProps = state => {
|
||||
AppPlatform: state.common.AppPlatform,
|
||||
AppReady: state.common.AppReady,
|
||||
DisplayConfiguration: state.mounts.DisplayConfiguration,
|
||||
DisplayError: state.error.DisplayError,
|
||||
DownloadActive: state.download.DownloadActive,
|
||||
DownloadType: state.download.DownloadType,
|
||||
InstallActive: state.install.InstallActive,
|
||||
@@ -492,6 +462,7 @@ const mapDispatchToProps = dispatch => {
|
||||
installRelease: (source, version, completedCallback) => dispatch(installRelease(source, version, completedCallback)),
|
||||
installUpgrade: (source, sha256, signature, skipVerification, completedCallback) => dispatch(installUpgrade(source, sha256, signature, skipVerification, completedCallback)),
|
||||
loadReleases: ()=> dispatch(loadReleases()),
|
||||
notifyError: (msg, critical, callback) => dispatch(notifyError(msg, critical, callback)),
|
||||
setActiveRelease: (release, version) => dispatch(setActiveRelease(release, version)),
|
||||
setAllowDownload: allow => dispatch(setAllowDownload(allow)),
|
||||
setDismissUIUpgrade: dismiss => dispatch(setDismissUIUpgrade(dismiss)),
|
||||
|
||||
Reference in New Issue
Block a user