[Fix new release detection] [IPC names to constants] [Refactoring]
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
import React from 'react';
|
||||
import {Component} from 'react';
|
||||
import * as Constants from '../../constants';
|
||||
import CSSModules from 'react-css-modules';
|
||||
import styles from './MountItems.css';
|
||||
import MountItem from '../../components/MountItem/MountItem';
|
||||
import {IPC_Detect_Mounts} from "../../constants";
|
||||
import {IPC_Mount_Drive} from "../../constants";
|
||||
import {IPC_Unmount_Drive} from "../../constants";
|
||||
|
||||
let ipcRenderer = null;
|
||||
if (!process.versions.hasOwnProperty('electron')) {
|
||||
@@ -13,9 +17,9 @@ class MountItems extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
if (ipcRenderer) {
|
||||
ipcRenderer.on('detect_mounts_reply', this.onDetectMountsReply);
|
||||
ipcRenderer.on('mount_drive_reply', this.onMountDriveReply);
|
||||
ipcRenderer.on('unmount_drive_reply', this.onUnmountDriveReply);
|
||||
ipcRenderer.on(Constants.IPC_Detect_Mounts_Reply, this.onDetectMountsReply);
|
||||
ipcRenderer.on(Constants.IPC_Mount_Drive_Reply, this.onMountDriveReply);
|
||||
ipcRenderer.on(Constants.IPC_Unmount_Drive_Reply, this.onUnmountDriveReply);
|
||||
|
||||
this.detectMounts();
|
||||
}
|
||||
@@ -38,15 +42,15 @@ class MountItems extends Component {
|
||||
|
||||
componentWillUnmount = () => {
|
||||
if (ipcRenderer) {
|
||||
ipcRenderer.removeListener('detect_mounts_reply', this.onDetectMountsReply);
|
||||
ipcRenderer.removeListener('mount_drive_reply', this.onMountDriveReply);
|
||||
ipcRenderer.removeListener('unmount_drive_reply', this.onUnmountDriveReply);
|
||||
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 = ()=> {
|
||||
this.props.mountsBusy(true);
|
||||
ipcRenderer.send('detect_mounts', {
|
||||
ipcRenderer.send(IPC_Detect_Mounts, {
|
||||
Directory: this.props.directory,
|
||||
Version: this.props.version,
|
||||
});
|
||||
@@ -74,14 +78,14 @@ class MountItems extends Component {
|
||||
this.props.mountsBusy(true);
|
||||
|
||||
if (mount) {
|
||||
ipcRenderer.send('mount_drive', {
|
||||
ipcRenderer.send(IPC_Mount_Drive, {
|
||||
Directory: this.props.directory,
|
||||
Location: location,
|
||||
StorageType: storageType,
|
||||
Version: this.props.version,
|
||||
});
|
||||
} else {
|
||||
ipcRenderer.send('unmount_drive', {
|
||||
ipcRenderer.send(IPC_Unmount_Drive, {
|
||||
Directory: this.props.directory,
|
||||
Location: location,
|
||||
PID: pid,
|
||||
|
||||
Reference in New Issue
Block a user