diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c3a266..43eaaa9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,12 @@ # Changelog # ## 1.0.2 ## -* Launch hidden (notification icon only) +* Option to launch application hidden (notification icon only) +* Close window to notification area +* Unmount on application exit +* Ability to cancel mount retry on unexpected failure * OS X support * SiaPrime support -* Unmount on application exit * Partial Linux support -* Close to notification area ## 1.0.1 ## * Added configuration settings for Repertory 1.0.0-alpha.2 and above diff --git a/src/containers/MountItems/MountItems.js b/src/containers/MountItems/MountItems.js index 7ba698f..5d3a6d7 100644 --- a/src/containers/MountItems/MountItems.js +++ b/src/containers/MountItems/MountItems.js @@ -1,8 +1,12 @@ import React from 'react'; import {Component} from 'react'; +import Box from '../../components/UI/Box/Box'; +import Button from '../../components/UI/Button/Button'; import CSSModules from 'react-css-modules'; import styles from './MountItems.css'; +import Modal from '../../components/UI/Modal/Modal'; import MountItem from '../../components/MountItem/MountItem'; +import RootElem from '../../hoc/RootElem/RootElem'; const Constants = require('../../constants'); @@ -30,9 +34,36 @@ class MountItems extends Component { } } - state = {}; + retryIntervals = {}; + + state = { + DisplayRetry: false, + RetryItems: {}, + }; + + cancelRetryMount = (storageType, stateCallback) => { + clearInterval(this.retryIntervals[storageType]); + delete this.retryIntervals[storageType]; + + if (stateCallback) { + let retryItems = { + ...this.state.RetryItems, + }; + delete retryItems[storageType]; + this.setState({ + DisplayRetry: Object.keys(retryItems) > 0, + RetryItems: retryItems, + }, stateCallback); + } + }; componentWillUnmount = () => { + for (const storageType in this.state.RetryItems) { + if (this.state.RetryItems.hasOwnProperty(storageType)) { + this.cancelRetryMount(storageType); + } + } + if (ipcRenderer) { ipcRenderer.removeListener(Constants.IPC_Detect_Mounts_Reply, this.onDetectMountsReply); ipcRenderer.removeListener(Constants.IPC_Mount_Drive_Reply, this.onMountDriveReply); @@ -160,7 +191,36 @@ class MountItems extends Component { onUnmountDriveReply = (event, arg) => { if (arg && arg.data && !arg.data.Expected && arg.data.Location && this.props[arg.data.StorageType.toLowerCase()].AutoRestart) { - this.handleMountUnMount(arg.data.StorageType, true, arg.data.Location) + const storageType = arg.data.StorageType; + if (!this.state.RetryItems[storageType]) { + let retryItems = { + ...this.state.RetryItems + }; + retryItems[storageType] = { + RetrySeconds: 10, + }; + this.setState({ + DisplayRetry: true, + RetryItems: retryItems, + }, () => { + this.retryIntervals[storageType] = setInterval(() => { + let retryItems = { + ...this.state.RetryItems, + }; + const retrySeconds = retryItems[storageType].RetrySeconds - 1; + if (retrySeconds === 0) { + this.cancelRetryMount(storageType, () => { + this.handleMountUnMount(storageType, true, arg.data.Location); + }); + } else { + retryItems[storageType].RetrySeconds = retrySeconds; + this.setState({ + RetryItems: retryItems, + }); + } + },1000); + }); + } } else { this.detectMounts(); } @@ -177,6 +237,7 @@ class MountItems extends Component { this.handleMountUnMount(provider, true, this.props[providerLower].MountLocation); } }; + for (const provider of Constants.PROVIDER_LIST) { processAutoMount(provider); } @@ -184,6 +245,30 @@ class MountItems extends Component { }; render() { + let retryDisplay; + if (this.state.DisplayRetry) { + let retryList = []; + for (const storageType in this.state.RetryItems) { + if (this.state.RetryItems.hasOwnProperty(storageType)) { + retryList.push(( + +

Retrying {storageType} in {this.state.RetryItems[storageType].RetrySeconds}(s)

+ +
+ )); + } + } + + retryDisplay = ( + + +

Mount Failed

+ {retryList} +
+
+ ) + } + let items = []; for (const provider of Constants.PROVIDER_LIST) { const providerLower = provider.toLowerCase(); @@ -212,6 +297,7 @@ class MountItems extends Component { return (
+ {retryDisplay} {items}
); }