Refactoring

This commit is contained in:
Scott E. Graves
2019-01-29 17:13:59 -06:00
parent a8f1724166
commit d16d417c99
5 changed files with 209 additions and 189 deletions

View File

@@ -259,7 +259,7 @@ const standardIPCReply = (event, channel, data, error) => {
} }
}; };
ipcMain.on(Constants.IPC_Browse_Directory, (event, data) => { ipcMain.on(Constants.IPC_Browse_Directory + '_sync', (event, data) => {
dialog.showOpenDialog(mainWindow, { dialog.showOpenDialog(mainWindow, {
defaultPath: data.Location, defaultPath: data.Location,
properties: ['openDirectory'], properties: ['openDirectory'],
@@ -286,6 +286,23 @@ ipcMain.on(Constants.IPC_Check_Dependency_Installed, (event, data) => {
} }
}); });
ipcMain.on(Constants.IPC_Check_Dependency_Installed + '_sync', (event, data) => {
try {
const exists = fs.lstatSync(data.File).isFile();
event.returnValue = {
data: {
Exists: exists
},
};
} catch (e) {
event.returnValue = {
data: {
Exists: false
},
};
}
});
ipcMain.on(Constants.IPC_Check_Installed, (event, data) => { ipcMain.on(Constants.IPC_Check_Installed, (event, data) => {
const dataDirectory = helpers.resolvePath(data.Directory); const dataDirectory = helpers.resolvePath(data.Directory);
const destination = path.join(dataDirectory, data.Version); const destination = path.join(dataDirectory, data.Version);
@@ -310,7 +327,7 @@ ipcMain.on(Constants.IPC_Check_Installed, (event, data) => {
}); });
}); });
ipcMain.on(Constants.IPC_Check_Mount_Location, (event, data) => { ipcMain.on(Constants.IPC_Check_Mount_Location + '_sync', (event, data) => {
let response = { let response = {
Success: true, Success: true,
Error: '' Error: ''
@@ -342,6 +359,21 @@ ipcMain.on(Constants.IPC_Delete_File, (event, data) => {
} }
}); });
ipcMain.on(Constants.IPC_Delete_File + '_sync', (event, data) => {
try {
if (fs.existsSync(data.FilePath)) {
fs.unlinkSync(data.FilePath);
}
event.returnValue = {
data: true,
};
} catch (e) {
event.returnValue = {
data: false,
};
}
});
ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => { ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
let driveLetters = {}; let driveLetters = {};
for (const provider of Constants.PROVIDER_LIST) { for (const provider of Constants.PROVIDER_LIST) {

View File

@@ -1,4 +1,4 @@
import React, {Component} from 'react'; import React from 'react';
import axios from 'axios'; import axios from 'axios';
import styles from './App.css'; import styles from './App.css';
import Box from './components/UI/Box/Box'; import Box from './components/UI/Box/Box';
@@ -15,16 +15,12 @@ import ReleaseVersionDisplay from './components/ReleaseVersionDisplay/ReleaseVer
import Text from './components/UI/Text/Text'; import Text from './components/UI/Text/Text';
import UpgradeIcon from './components/UpgradeIcon/UpgradeIcon'; import UpgradeIcon from './components/UpgradeIcon/UpgradeIcon';
import UpgradeUI from './components/UpgradeUI/UpgradeUI'; import UpgradeUI from './components/UpgradeUI/UpgradeUI';
import IPCContainer from './containers/IPCContainer/IPCContainer';
const Constants = require('./constants'); const Constants = require('./constants');
const Scheduler = require('node-schedule'); const Scheduler = require('node-schedule');
let ipcRenderer = null; class App extends IPCContainer {
if (!process.versions.hasOwnProperty('electron')) {
ipcRenderer = ((window && window.require) ? window.require('electron').ipcRenderer : null);
}
class App extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
@@ -36,21 +32,19 @@ class App extends Component {
} }
} }
if (ipcRenderer) { this.setRequestHandler(Constants.IPC_Check_Installed_Reply, this.onCheckInstalledReply);
ipcRenderer.on(Constants.IPC_Check_Installed_Reply, this.onCheckInstalledReply); this.setRequestHandler(Constants.IPC_Download_File_Complete, this.onDownloadFileComplete);
ipcRenderer.on(Constants.IPC_Download_File_Complete, this.onDownloadFileComplete); this.setRequestHandler(Constants.IPC_Download_File_Progress, this.onDownloadFileProgress);
ipcRenderer.on(Constants.IPC_Download_File_Progress, this.onDownloadFileProgress); this.setRequestHandler(Constants.IPC_Extract_Release_Complete, this.onExtractReleaseComplete);
ipcRenderer.on(Constants.IPC_Extract_Release_Complete, this.onExtractReleaseComplete); this.setRequestHandler(Constants.IPC_Get_State_Reply, this.onGetStateReply);
ipcRenderer.on(Constants.IPC_Get_State_Reply, this.onGetStateReply); this.setRequestHandler(Constants.IPC_Grab_Releases_Reply, this.onGrabReleasesReply);
ipcRenderer.on(Constants.IPC_Grab_Releases_Reply, this.onGrabReleasesReply); this.setRequestHandler(Constants.IPC_Grab_UI_Releases_Reply, this.onGrabUiReleasesReply);
ipcRenderer.on(Constants.IPC_Grab_UI_Releases_Reply, this.onGrabUiReleasesReply); this.setRequestHandler(Constants.IPC_Install_Dependency_Reply, this.onInstallDependencyReply);
ipcRenderer.on(Constants.IPC_Install_Dependency_Reply, this.onInstallDependencyReply); this.setRequestHandler(Constants.IPC_Install_Upgrade_Reply, this.onInstallUpgradeReply);
ipcRenderer.on(Constants.IPC_Install_Upgrade_Reply, this.onInstallUpgradeReply);
ipcRenderer.send(Constants.IPC_Get_State, Constants.DATA_LOCATIONS[this.props.platform]); this.sendRequest(Constants.IPC_Get_State, Constants.DATA_LOCATIONS[this.props.platform]);
Scheduler.scheduleJob('23 11 * * *', this.updateCheckScheduledJob); Scheduler.scheduleJob('23 11 * * *', this.updateCheckScheduledJob);
} }
}
state = { state = {
AllowDownload: false, AllowDownload: false,
@@ -106,19 +100,17 @@ class App extends Component {
}, ()=> { }, ()=> {
const selectedVersion = this.getSelectedVersion(); const selectedVersion = this.getSelectedVersion();
if (selectedVersion !== 'unavailable') { if (selectedVersion !== 'unavailable') {
if (ipcRenderer) {
let dependencies = []; let dependencies = [];
if (this.state.LocationsLookup[selectedVersion] && this.state.LocationsLookup[selectedVersion].dependencies) { if (this.state.LocationsLookup[selectedVersion] && this.state.LocationsLookup[selectedVersion].dependencies) {
dependencies = this.state.LocationsLookup[selectedVersion].dependencies; dependencies = this.state.LocationsLookup[selectedVersion].dependencies;
} }
ipcRenderer.send(Constants.IPC_Check_Installed, { this.sendRequest(Constants.IPC_Check_Installed, {
Dependencies: dependencies, Dependencies: dependencies,
Directory: Constants.DATA_LOCATIONS[this.props.platform], Directory: Constants.DATA_LOCATIONS[this.props.platform],
Version: selectedVersion, Version: selectedVersion,
}); });
} }
}
}); });
}; };
@@ -128,9 +120,7 @@ class App extends Component {
} }
if (this.state.ErrorCritical) { if (this.state.ErrorCritical) {
if (ipcRenderer) { this.sendRequest(Constants.IPC_Shutdown);
ipcRenderer.send(Constants.IPC_Shutdown);
}
} else { } else {
this.setState({ this.setState({
DisplayError: false, DisplayError: false,
@@ -139,20 +129,6 @@ class App extends Component {
} }
}; };
componentWillUnmount = () => {
if (ipcRenderer) {
ipcRenderer.removeListener(Constants.IPC_Check_Installed_Reply, this.onCheckInstalledReply);
ipcRenderer.removeListener(Constants.IPC_Download_File_Complete, this.onDownloadFileComplete);
ipcRenderer.removeListener(Constants.IPC_Download_File_Progress, this.onDownloadFileProgress);
ipcRenderer.removeListener(Constants.IPC_Extract_Release_Complete, this.onExtractReleaseComplete);
ipcRenderer.removeListener(Constants.IPC_Get_State_Reply, this.onGetStateReply);
ipcRenderer.removeListener(Constants.IPC_Grab_Releases_Reply, this.onGrabReleasesReply);
ipcRenderer.removeListener(Constants.IPC_Grab_UI_Releases_Reply, this.onGrabUiReleasesReply);
ipcRenderer.removeListener(Constants.IPC_Install_Dependency_Reply, this.onInstallDependencyReply);
ipcRenderer.removeListener(Constants.IPC_Install_Upgrade_Reply, this.onInstallUpgradeReply);
}
};
extractFileNameFromURL = url => { extractFileNameFromURL = url => {
const parts = url.split('/'); const parts = url.split('/');
return parts[parts.length - 1]; return parts[parts.length - 1];
@@ -161,7 +137,7 @@ class App extends Component {
extractRelease = (data) => { extractRelease = (data) => {
if (data.Success) { if (data.Success) {
const selectedVersion = this.getSelectedVersion(); const selectedVersion = this.getSelectedVersion();
ipcRenderer.send(Constants.IPC_Extract_Release, { this.sendRequest(Constants.IPC_Extract_Release, {
Directory: Constants.DATA_LOCATIONS[this.props.platform], Directory: Constants.DATA_LOCATIONS[this.props.platform],
Source: data.Destination, Source: data.Destination,
Version: selectedVersion, Version: selectedVersion,
@@ -183,10 +159,8 @@ class App extends Component {
grabReleases = () => { grabReleases = () => {
if (this.props.platform !== 'unknown') { if (this.props.platform !== 'unknown') {
if (ipcRenderer) { this.sendRequest(Constants.IPC_Grab_Releases);
ipcRenderer.send(Constants.IPC_Grab_Releases); this.sendRequest(Constants.IPC_Grab_UI_Releases);
ipcRenderer.send(Constants.IPC_Grab_UI_Releases);
}
} }
}; };
@@ -227,19 +201,17 @@ class App extends Component {
}; };
handleDependencyDownload = (url) => { handleDependencyDownload = (url) => {
if (ipcRenderer) {
this.setState({ this.setState({
DownloadActive: true, DownloadActive: true,
DownloadingDependency: true, DownloadingDependency: true,
DownloadName: this.extractFileNameFromURL(url), DownloadName: this.extractFileNameFromURL(url),
}, ()=> { }, ()=> {
ipcRenderer.send(Constants.IPC_Download_File, { this.sendRequest(Constants.IPC_Download_File, {
Directory: Constants.DATA_LOCATIONS[this.props.platform], Directory: Constants.DATA_LOCATIONS[this.props.platform],
Filename: this.state.DownloadName, Filename: this.state.DownloadName,
URL: url, URL: url,
}); });
}); });
}
}; };
handleMountLocationChanged = (storageType, location) => { handleMountLocationChanged = (storageType, location) => {
@@ -269,38 +241,32 @@ class App extends Component {
handleReleaseDownload = () => { handleReleaseDownload = () => {
const selectedVersion = this.getSelectedVersion(); const selectedVersion = this.getSelectedVersion();
const fileName = selectedVersion + '.zip'; const fileName = selectedVersion + '.zip';
if (ipcRenderer) {
this.setState({ this.setState({
DownloadActive: true, DownloadActive: true,
DownloadingRelease: true, DownloadingRelease: true,
DownloadName: fileName, DownloadName: fileName,
}, () => { }, () => {
ipcRenderer.send(Constants.IPC_Download_File, { this.sendRequest(Constants.IPC_Download_File, {
Directory: Constants.DATA_LOCATIONS[this.props.platform], Directory: Constants.DATA_LOCATIONS[this.props.platform],
Filename: this.state.DownloadName, Filename: this.state.DownloadName,
URL: this.state.LocationsLookup[selectedVersion].urls[0], URL: this.state.LocationsLookup[selectedVersion].urls[0],
}); });
}); });
}
}; };
handleUIDownload = () => { handleUIDownload = () => {
if (ipcRenderer) {
this.setState({ this.setState({
DownloadActive: true, DownloadActive: true,
DownloadingUpgrade: true, DownloadingUpgrade: true,
DownloadName: 'UI Upgrade', DownloadName: 'UI Upgrade',
}, ()=> { }, ()=> {
const url = this.state.UpgradeData.urls[0]; const url = this.state.UpgradeData.urls[0];
ipcRenderer.send(Constants.IPC_Download_File, { this.sendRequest(Constants.IPC_Download_File, {
Directory: Constants.DATA_LOCATIONS[this.props.platform], Directory: Constants.DATA_LOCATIONS[this.props.platform],
Filename: this.props.platform === 'win32' ? 'upgrade.exe' : this.extractFileNameFromURL(url), Filename: this.props.platform === 'win32' ? 'upgrade.exe' : this.extractFileNameFromURL(url),
URL: url, URL: url,
}); });
}); });
} else {
this.setState({UpgradeDismissed: true});
}
}; };
handleVersionChanged = (e) => { handleVersionChanged = (e) => {
@@ -314,7 +280,7 @@ class App extends Component {
installDependency = data => { installDependency = data => {
if (data.Success) { if (data.Success) {
ipcRenderer.send(Constants.IPC_Install_Dependency, { this.sendRequest(Constants.IPC_Install_Dependency, {
Source: data.Destination, Source: data.Destination,
URL: data.URL, URL: data.URL,
}); });
@@ -330,7 +296,7 @@ class App extends Component {
installUpgrade = data => { installUpgrade = data => {
if (data.Success) { if (data.Success) {
ipcRenderer.send(Constants.IPC_Install_Upgrade, { this.sendRequest(Constants.IPC_Install_Upgrade, {
Source: data.Destination, Source: data.Destination,
}); });
} else { } else {
@@ -404,7 +370,7 @@ class App extends Component {
}; };
onExtractReleaseComplete = (event, arg) => { onExtractReleaseComplete = (event, arg) => {
ipcRenderer.send(Constants.IPC_Delete_File, { this.sendRequest(Constants.IPC_Delete_File, {
FilePath: arg.data.Source, FilePath: arg.data.Source,
}); });
@@ -521,7 +487,7 @@ class App extends Component {
if (arg.data.Success && arg.data.Source.toLowerCase().endsWith('.dmg')) { if (arg.data.Success && arg.data.Source.toLowerCase().endsWith('.dmg')) {
this.waitForDependencyInstall(arg.data.URL); this.waitForDependencyInstall(arg.data.URL);
} else { } else {
ipcRenderer.send(Constants.IPC_Delete_File, { this.sendRequest(Constants.IPC_Delete_File, {
FilePath: arg.data.Source, FilePath: arg.data.Source,
}); });
this.checkVersionInstalled(); this.checkVersionInstalled();
@@ -529,7 +495,7 @@ class App extends Component {
}; };
onInstallUpgradeReply = (event, arg) => { onInstallUpgradeReply = (event, arg) => {
ipcRenderer.sendSync(Constants.IPC_Delete_File, { this.sendSyncRequest(Constants.IPC_Delete_File, {
FilePath: arg.data.Source, FilePath: arg.data.Source,
}); });
@@ -541,7 +507,6 @@ class App extends Component {
}; };
saveState = version => { saveState = version => {
if (ipcRenderer) {
let state = { let state = {
Release: this.state.Release, Release: this.state.Release,
Version: version || this.state.Version, Version: version || this.state.Version,
@@ -550,11 +515,10 @@ class App extends Component {
state[provider] = this.state[provider]; state[provider] = this.state[provider];
} }
ipcRenderer.send(Constants.IPC_Save_State, { this.sendRequest(Constants.IPC_Save_State, {
Directory: Constants.DATA_LOCATIONS[this.props.platform], Directory: Constants.DATA_LOCATIONS[this.props.platform],
State: state State: state
}); });
}
}; };
setErrorState = (error, action, critical) => { setErrorState = (error, action, critical) => {
@@ -578,7 +542,7 @@ class App extends Component {
}); });
const i = setInterval(()=> { const i = setInterval(()=> {
const ret = ipcRenderer.sendSync(Constants.IPC_Check_Dependency_Installed, { const ret = this.sendSyncRequest(Constants.IPC_Check_Dependency_Installed, {
File: dep.file, File: dep.file,
}); });
if (ret.data.Exists || !ret.data.Success) { if (ret.data.Exists || !ret.data.Success) {

View File

@@ -5,29 +5,23 @@ import Button from '../../components/UI/Button/Button';
import ConfigurationItem from '../../components/ConfigurationItem/ConfigurationItem'; import ConfigurationItem from '../../components/ConfigurationItem/ConfigurationItem';
import CSSModules from 'react-css-modules'; import CSSModules from 'react-css-modules';
import Modal from '../../components/UI/Modal/Modal'; import Modal from '../../components/UI/Modal/Modal';
import IPCContainer from '../IPCContainer/IPCContainer';
const Constants = require('../../constants'); const Constants = require('../../constants');
let ipcRenderer = null; class Configuration extends IPCContainer {
if (!process.versions.hasOwnProperty('electron')) {
ipcRenderer = ((window && window.require) ? window.require('electron').ipcRenderer : null);
}
class Configuration extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
if (ipcRenderer) { this.setRequestHandler(Constants.IPC_Get_Config_Template_Reply, this.onGetConfigTemplateReply);
ipcRenderer.on(Constants.IPC_Get_Config_Template_Reply, this.onGetConfigTemplateReply); this.setRequestHandler(Constants.IPC_Get_Config_Reply, this.onGetConfigReply);
ipcRenderer.on(Constants.IPC_Get_Config_Reply, this.onGetConfigReply); this.setRequestHandler(Constants.IPC_Set_Config_Values_Reply, this.onSetConfigValuesReply);
ipcRenderer.on(Constants.IPC_Set_Config_Values_Reply, this.onSetConfigValuesReply);
ipcRenderer.send(Constants.IPC_Get_Config_Template, { this.sendRequest(Constants.IPC_Get_Config_Template, {
Directory: this.props.directory, Directory: this.props.directory,
StorageType: this.props.storageType, StorageType: this.props.storageType,
Version: this.props.version, Version: this.props.version,
}); });
} }
}
state = { state = {
ChangedItems: [], ChangedItems: [],
@@ -78,14 +72,6 @@ class Configuration extends Component {
} }
}; };
componentWillUnmount = () => {
if (ipcRenderer) {
ipcRenderer.removeListener(Constants.IPC_Get_Config_Reply, this.onGetConfigReply);
ipcRenderer.removeListener(Constants.IPC_Get_Config_Template_Reply, this.onGetConfigTemplateReply);
ipcRenderer.removeListener(Constants.IPC_Set_Config_Values_Reply, this.onSetConfigValuesReply);
}
};
createItemList = (config, template) => { createItemList = (config, template) => {
const objectList = []; const objectList = [];
const itemList = Object const itemList = Object
@@ -165,7 +151,7 @@ class Configuration extends Component {
this.setState({ this.setState({
Template: arg.data.Template, Template: arg.data.Template,
}, ()=> { }, ()=> {
ipcRenderer.send(Constants.IPC_Get_Config, { this.sendRequest(Constants.IPC_Get_Config, {
Directory: this.props.directory, Directory: this.props.directory,
StorageType: this.props.storageType, StorageType: this.props.storageType,
Version: this.props.version, Version: this.props.version,
@@ -183,7 +169,6 @@ class Configuration extends Component {
}; };
saveAndClose = () => { saveAndClose = () => {
if (ipcRenderer) {
this.setState({ this.setState({
Saving: true, Saving: true,
}, ()=> { }, ()=> {
@@ -206,14 +191,13 @@ class Configuration extends Component {
} }
} }
ipcRenderer.send(Constants.IPC_Set_Config_Values, { this.sendRequest(Constants.IPC_Set_Config_Values, {
Directory: this.props.directory, Directory: this.props.directory,
Items: changedItems, Items: changedItems,
StorageType: this.props.storageType, StorageType: this.props.storageType,
Version: this.props.version, Version: this.props.version,
}); });
}); });
}
}; };
render() { render() {

View File

@@ -0,0 +1,51 @@
import {Component} from 'react';
export default class extends Component {
constructor(props) {
super(props);
if (!process.versions.hasOwnProperty('electron')) {
this.ipcRenderer = ((window && window.require) ? window.require('electron').ipcRenderer : null);
}
}
handlerList = {};
ipcRenderer;
componentWillUnmount() {
if (this.ipcRenderer) {
for (let name in this.handlerList) {
if (this.handlerList.hasOwnProperty(name)) {
this.ipcRenderer.removeListener(name, this.handlerList[name]);
}
}
}
this.handlerList = {};
};
sendRequest = (name, data) => {
if (this.ipcRenderer) {
this.ipcRenderer.send(name, data);
}
};
sendSyncRequest = (name, data) => {
if (this.ipcRenderer) {
return this.ipcRenderer.sendSync(name + '_sync', data);
} else {
return {
Success: false,
Error: 'IPC not available. Running in browser?',
};
}
};
setRequestHandler = (name, callback) => {
if (this.ipcRenderer) {
this.handlerList[name] = callback;
this.ipcRenderer.on(name, callback);
}
};
};

View File

@@ -1,20 +1,15 @@
import React from 'react'; import React from 'react';
import {Component} from 'react';
import Box from '../../components/UI/Box/Box'; import Box from '../../components/UI/Box/Box';
import Button from '../../components/UI/Button/Button'; import Button from '../../components/UI/Button/Button';
import CSSModules from 'react-css-modules'; import CSSModules from 'react-css-modules';
import styles from './MountItems.css'; import styles from './MountItems.css';
import Modal from '../../components/UI/Modal/Modal'; import Modal from '../../components/UI/Modal/Modal';
import MountItem from '../../components/MountItem/MountItem'; import MountItem from '../../components/MountItem/MountItem';
import IPCContainer from '../IPCContainer/IPCContainer';
const Constants = require('../../constants'); const Constants = require('../../constants');
let ipcRenderer = null; class MountItems extends IPCContainer {
if (!process.versions.hasOwnProperty('electron')) {
ipcRenderer = ((window && window.require) ? window.require('electron').ipcRenderer : null);
}
class MountItems extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
@@ -26,14 +21,12 @@ class MountItems extends Component {
}; };
} }
if (ipcRenderer) { this.setRequestHandler(Constants.IPC_Detect_Mounts_Reply, this.onDetectMountsReply);
ipcRenderer.on(Constants.IPC_Detect_Mounts_Reply, this.onDetectMountsReply); this.setRequestHandler(Constants.IPC_Mount_Drive_Reply, this.onMountDriveReply);
ipcRenderer.on(Constants.IPC_Mount_Drive_Reply, this.onMountDriveReply); this.setRequestHandler(Constants.IPC_Unmount_Drive_Reply, this.onUnmountDriveReply);
ipcRenderer.on(Constants.IPC_Unmount_Drive_Reply, this.onUnmountDriveReply);
this.detectMounts(); this.detectMounts();
} }
}
retryIntervals = {}; retryIntervals = {};
@@ -58,24 +51,20 @@ class MountItems extends Component {
} }
}; };
componentWillUnmount = () => { componentWillUnmount() {
for (const storageType in this.state.RetryItems) { for (const storageType in this.state.RetryItems) {
if (this.state.RetryItems.hasOwnProperty(storageType)) { if (this.state.RetryItems.hasOwnProperty(storageType)) {
this.cancelRetryMount(storageType); this.cancelRetryMount(storageType);
} }
} }
if (ipcRenderer) { super.componentWillUnmount();
ipcRenderer.removeListener(Constants.IPC_Detect_Mounts_Reply, this.onDetectMountsReply);
ipcRenderer.removeListener(Constants.IPC_Mount_Drive_Reply, this.onMountDriveReply);
ipcRenderer.removeListener(Constants.IPC_Unmount_Drive_Reply, this.onUnmountDriveReply);
}
}; };
detectMounts = ()=> { detectMounts = ()=> {
if (!this.state.DisplayRetry) { if (!this.state.DisplayRetry) {
this.props.mountsBusy(true); this.props.mountsBusy(true);
ipcRenderer.send(Constants.IPC_Detect_Mounts, { this.sendRequest(Constants.IPC_Detect_Mounts, {
Directory: this.props.directory, Directory: this.props.directory,
Version: this.props.version, Version: this.props.version,
}); });
@@ -83,7 +72,7 @@ class MountItems extends Component {
}; };
handleBrowseLocation = (storageType, location) => { handleBrowseLocation = (storageType, location) => {
location = ipcRenderer.sendSync(Constants.IPC_Browse_Directory, { location = this.sendSyncRequest(Constants.IPC_Browse_Directory, {
Title: storageType + ' Mount Location', Title: storageType + ' Mount Location',
Location: location, Location: location,
}); });
@@ -103,10 +92,10 @@ class MountItems extends Component {
handleMountUnMount = (storageType, mount, location) => { handleMountUnMount = (storageType, mount, location) => {
if (!location || (location.trim().length === 0)) { if (!location || (location.trim().length === 0)) {
this.props.errorHandler('Mount location is not set'); this.props.errorHandler('Mount location is not set');
} else if (ipcRenderer) { } else {
let allowAction = true; let allowAction = true;
if (mount && (this.props.platform !== 'win32')) { if (mount && (this.props.platform !== 'win32')) {
const result = ipcRenderer.sendSync(Constants.IPC_Check_Mount_Location, { const result = this.sendSyncRequest(Constants.IPC_Check_Mount_Location, {
Location: location, Location: location,
}); });
if (!result.Success) { if (!result.Success) {
@@ -127,7 +116,7 @@ class MountItems extends Component {
[storageType]: storageState, [storageType]: storageState,
}, () => { }, () => {
if (mount) { if (mount) {
ipcRenderer.send(Constants.IPC_Mount_Drive, { this.sendRequest(Constants.IPC_Mount_Drive, {
Directory: this.props.directory, Directory: this.props.directory,
Location: location, Location: location,
NoConsoleSupported: this.props.noConsoleSupported, NoConsoleSupported: this.props.noConsoleSupported,
@@ -135,7 +124,7 @@ class MountItems extends Component {
Version: this.props.version, Version: this.props.version,
}); });
} else { } else {
ipcRenderer.send(Constants.IPC_Unmount_Drive, { this.sendRequest(Constants.IPC_Unmount_Drive, {
Directory: this.props.directory, Directory: this.props.directory,
Location: location, Location: location,
StorageType: storageType, StorageType: storageType,