diff --git a/src/components/ErrorDetails/ErrorDetails.js b/src/components/ErrorDetails/ErrorDetails.js index 571367b..a0894b6 100644 --- a/src/components/ErrorDetails/ErrorDetails.js +++ b/src/components/ErrorDetails/ErrorDetails.js @@ -19,7 +19,7 @@ const mapDispatchToProps = dispatch => { export default connect(mapStateToProps, mapDispatchToProps)(props => { return ( - +

Application Error

{props.ErrorMessage}

diff --git a/src/containers/MountItems/MountItems.js b/src/containers/MountItems/MountItems.js index c26c456..023052f 100644 --- a/src/containers/MountItems/MountItems.js +++ b/src/containers/MountItems/MountItems.js @@ -78,6 +78,46 @@ class MountItems extends IPCContainer { } }; + displayRetryMount = (provider, mountLocation, msg) => { + if (!this.state.RetryItems[provider]) { + let retryItems = { + ...this.state.RetryItems + }; + retryItems[provider] = { + RetrySeconds: 10, + RetryMessage: msg ? msg.toString() : null, + }; + const mountState = { + AllowMount: false, + Mounted: false, + }; + this.props.setMountState(provider, mountState); + + this.setState({ + DisplayRetry: true, + RetryItems: retryItems, + }, () => { + this.sendRequest(Constants.IPC_Show_Window); + this.retryIntervals[provider] = setInterval(() => { + let retryItems = { + ...this.state.RetryItems, + }; + const retrySeconds = retryItems[provider].RetrySeconds - 1; + if (retrySeconds === 0) { + this.cancelRetryMount(provider, () => { + this.handleMountUnMount(provider, true, mountLocation); + }); + } else { + retryItems[provider].RetrySeconds = retrySeconds; + this.setState({ + RetryItems: retryItems, + }); + } + }, 1000); + }); + } + }; + handleBrowseLocation = (provider, location) => { location = this.sendSyncRequest(Constants.IPC_Browse_Directory, { Title: provider + ' Mount Location', @@ -123,17 +163,17 @@ class MountItems extends IPCContainer { } } else { allowAction = false; - if (result.Code === (new Uint32Array([-1]))[0]) { - this.props.notifyError('Failed to connect to ' + provider + ' daemon'); - } else if (result.Code === (new Uint32Array([-3]))[0]) { - this.props.notifyError('Incompatible ' + provider + ' daemon. Please upgrade ' + provider); + if ((result.Code === new Uint32Array([-1])[0]) || (result.Code === new Uint8Array([-1])[0])) { + this.displayRetryMount(provider, location, 'Failed to connect to ' + provider + ' daemon'); + } else if ((result.Code === new Uint32Array([-3])[0]) || (result.Code === new Uint8Array([-3])[0])) { + this.displayRetryMount(provider, location, 'Incompatible ' + provider + ' daemon. Please upgrade ' + provider); } else { - this.props.notifyError('Version check failed: ' + result.Error); + this.displayRetryMount(provider, location, 'Version check failed: ' + result.Error); } } } else { allowAction = false; - this.props.notifyError(result.Error.toString()); + this.displayRetryMount(provider, location, 'Version check failed: ' + result.Error); } } @@ -213,43 +253,7 @@ class MountItems extends IPCContainer { onUnmountDriveReply = (event, arg) => { if (arg && arg.data && !arg.data.Expected && arg.data.Location && this.props.ProviderState[arg.data.Provider].AutoRestart) { - const provider = arg.data.Provider; - if (!this.state.RetryItems[provider]) { - let retryItems = { - ...this.state.RetryItems - }; - retryItems[provider] = { - RetrySeconds: 10, - }; - const mountState = { - AllowMount: false, - Mounted: false, - }; - this.props.setMountState(provider, mountState); - - this.setState({ - DisplayRetry: true, - RetryItems: retryItems, - }, () => { - this.sendRequest(Constants.IPC_Show_Window); - this.retryIntervals[provider] = setInterval(() => { - let retryItems = { - ...this.state.RetryItems, - }; - const retrySeconds = retryItems[provider].RetrySeconds - 1; - if (retrySeconds === 0) { - this.cancelRetryMount(provider, () => { - this.handleMountUnMount(provider, true, arg.data.Location); - }); - } else { - retryItems[provider].RetrySeconds = retrySeconds; - this.setState({ - RetryItems: retryItems, - }); - } - },1000); - }); - } + this.displayRetryMount(arg.data.Provider, arg.data.Location); } else { this.detectMounts(); } @@ -263,6 +267,9 @@ class MountItems extends IPCContainer { for (const provider in this.state.RetryItems) { if (this.state.RetryItems.hasOwnProperty(provider)) { retryListCount++; + if (this.state.RetryItems[provider].RetryMessage) { + retryList.push(

{this.state.RetryItems[provider].RetryMessage}

); + } retryList.push(); @@ -274,7 +281,7 @@ class MountItems extends IPCContainer { retryDisplay = ( - +

Mount Failed

{retryList}