From fc5b9e0a864197823a358b54250e86621397642c Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Tue, 16 Jul 2019 14:10:32 -0500 Subject: [PATCH] #29: Mounts aren't being detected properly when switching releases --- CHANGELOG.md | 1 + src/containers/Configuration/Configuration.js | 11 +++-------- src/containers/MountItems/MountItems.js | 16 ++++++++-------- src/redux/actions/mount_actions.js | 7 +++++++ src/redux/reducers/mount_reducer.js | 8 ++++++++ 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfb5d25..0a4a85c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog # ## 1.0.5 ## +* \#29: Mounts aren't being detected properly when switching releases * Display window when dependencies are missing * Display window when UI upgrade is available diff --git a/src/containers/Configuration/Configuration.js b/src/containers/Configuration/Configuration.js index f7f3e17..46ac070 100644 --- a/src/containers/Configuration/Configuration.js +++ b/src/containers/Configuration/Configuration.js @@ -12,14 +12,6 @@ import {notifyError} from '../../redux/actions/error_actions'; const Constants = require('../../constants'); class Configuration extends IPCContainer { - constructor(props) { - super(props); - - this.setRequestHandler(Constants.IPC_Get_Config_Template_Reply, this.onGetConfigTemplateReply); - this.setRequestHandler(Constants.IPC_Get_Config_Reply, this.onGetConfigReply); - this.setRequestHandler(Constants.IPC_Set_Config_Values_Reply, this.onSetConfigValuesReply); - } - _isMounted = false; state = { @@ -73,6 +65,9 @@ class Configuration extends IPCContainer { componentDidMount() { this._isMounted = true; + this.setRequestHandler(Constants.IPC_Get_Config_Template_Reply, this.onGetConfigTemplateReply); + this.setRequestHandler(Constants.IPC_Get_Config_Reply, this.onGetConfigReply); + this.setRequestHandler(Constants.IPC_Set_Config_Values_Reply, this.onSetConfigValuesReply); this.sendRequest(Constants.IPC_Get_Config_Template, { Provider: this.props.DisplayConfiguration, Version: this.props.version, diff --git a/src/containers/MountItems/MountItems.js b/src/containers/MountItems/MountItems.js index 6bf55b6..2317438 100644 --- a/src/containers/MountItems/MountItems.js +++ b/src/containers/MountItems/MountItems.js @@ -7,6 +7,7 @@ import Modal from '../../components/UI/Modal/Modal'; import MountItem from '../../components/MountItem/MountItem'; import IPCContainer from '../IPCContainer/IPCContainer'; import { + resetMountsState, setAllowMount, setAutoMountProcessed, setBusy, @@ -19,14 +20,6 @@ import {notifyError} from '../../redux/actions/error_actions'; const Constants = require('../../constants'); class MountItems extends IPCContainer { - constructor(props) { - super(props); - - this.setRequestHandler(Constants.IPC_Detect_Mounts_Reply, this.onDetectMountsReply); - this.setRequestHandler(Constants.IPC_Mount_Drive_Reply, this.onMountDriveReply); - this.setRequestHandler(Constants.IPC_Unmount_Drive_Reply, this.onUnmountDriveReply); - } - retryIntervals = {}; state = { @@ -56,6 +49,10 @@ class MountItems extends IPCContainer { }; componentDidMount() { + this.setRequestHandler(Constants.IPC_Detect_Mounts_Reply, this.onDetectMountsReply); + this.setRequestHandler(Constants.IPC_Mount_Drive_Reply, this.onMountDriveReply); + this.setRequestHandler(Constants.IPC_Unmount_Drive_Reply, this.onUnmountDriveReply); + this.props.resetMountsState(); this.detectMounts(); } @@ -66,6 +63,7 @@ class MountItems extends IPCContainer { } } + this.props.resetMountsState(); super.componentWillUnmount(); }; @@ -318,6 +316,7 @@ const mapStateToProps = state => { AutoMountProcessed: state.mounts.AutoMountProcessed, InstalledVersion: state.relver.InstalledVersion, MountState: state.mounts.MountState, + MountsBusy: state.mounts.MountsBusy, Platform: state.common.Platform, ProviderState: state.mounts.ProviderState, } @@ -326,6 +325,7 @@ const mapStateToProps = state => { const mapDispatchToProps = dispatch => { return { notifyError: (msg, critical, callback) => dispatch(notifyError(msg, critical, callback)), + resetMountsState: () => dispatch(resetMountsState()), setAllowMount: (provider, allow) => dispatch(setAllowMount(provider, allow)), setAutoMountProcessed: processed => dispatch(setAutoMountProcessed(processed)), setMounted: (provider, mounted) => dispatch(setMounted(provider, mounted)), diff --git a/src/redux/actions/mount_actions.js b/src/redux/actions/mount_actions.js index 357c801..37348a7 100644 --- a/src/redux/actions/mount_actions.js +++ b/src/redux/actions/mount_actions.js @@ -2,6 +2,13 @@ import {createAction} from 'redux-starter-kit'; export const displayConfiguration = createAction('mounts/displayConfiguration'); +export const RESET_MOUNTS_STATE = 'mounts/resetMountsState'; +export const resetMountsState = () => { + return { + type: RESET_MOUNTS_STATE, + payload: null, + } +}; export const SET_ALLOW_MOUNT = 'mounts/setAllowMount'; export const setAllowMount = (provider, allow) => { return { diff --git a/src/redux/reducers/mount_reducer.js b/src/redux/reducers/mount_reducer.js index dbbfbd2..75e25a7 100644 --- a/src/redux/reducers/mount_reducer.js +++ b/src/redux/reducers/mount_reducer.js @@ -2,6 +2,7 @@ import * as Constants from '../../constants'; import {createReducer} from 'redux-starter-kit'; import { displayConfiguration, + RESET_MOUNTS_STATE, SET_ALLOW_MOUNT, setAutoMountProcessed, setBusy, @@ -53,6 +54,13 @@ export const mountReducer = createReducer({ DisplayConfiguration: action.payload }; }, + [RESET_MOUNTS_STATE]: (state, action) => { + return { + ...state, + MountsBusy: false, + MountState: mountState, + } + }, [setAutoMountProcessed]: (state, action) => { return { ...state,