[Fix new release detection] [IPC names to constants] [Refactoring]
This commit is contained in:
@@ -3,6 +3,7 @@ import styles from './Configuration.css';
|
||||
import Box from '../../components/UI/Box/Box';
|
||||
import Button from '../../components/UI/Button/Button';
|
||||
import ConfigurationItem from '../../components/ConfigurationItem/ConfigurationItem';
|
||||
import * as Constants from '../../constants';
|
||||
import CSSModules from 'react-css-modules';
|
||||
import Modal from '../../components/UI/Modal/Modal';
|
||||
|
||||
@@ -15,11 +16,11 @@ class Configuration extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
if (ipcRenderer) {
|
||||
ipcRenderer.on('get_config_template_reply', this.onGetConfigTemplateReply);
|
||||
ipcRenderer.on('get_config_reply', this.onGetConfigReply);
|
||||
ipcRenderer.on('set_config_values_reply', this.onSetConfigValuesReply);
|
||||
ipcRenderer.on(Constants.IPC_Get_Config_Template_Reply, this.onGetConfigTemplateReply);
|
||||
ipcRenderer.on(Constants.IPC_Get_Config_Reply, this.onGetConfigReply);
|
||||
ipcRenderer.on(Constants.IPC_Set_Config_Values_Reply, this.onSetConfigValuesReply);
|
||||
|
||||
ipcRenderer.send('get_config_template', {
|
||||
ipcRenderer.send(Constants.IPC_Get_Config_Template, {
|
||||
Directory: this.props.directory,
|
||||
StorageType: this.props.storageType,
|
||||
Version: this.props.version,
|
||||
@@ -78,9 +79,9 @@ class Configuration extends Component {
|
||||
|
||||
componentWillUnmount = () => {
|
||||
if (ipcRenderer) {
|
||||
ipcRenderer.removeListener('get_config_reply', this.onGetConfigReply);
|
||||
ipcRenderer.removeListener('get_config_template_reply', this.onGetConfigTemplateReply);
|
||||
ipcRenderer.removeListener('set_config_values', this.onSetConfigValuesReply);
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -161,7 +162,7 @@ class Configuration extends Component {
|
||||
this.setState({
|
||||
Template: arg.data.Template,
|
||||
});
|
||||
ipcRenderer.send('get_config', {
|
||||
ipcRenderer.send(Constants.IPC_Get_Config, {
|
||||
Directory: this.props.directory,
|
||||
StorageType: this.props.storageType,
|
||||
Version: this.props.version,
|
||||
@@ -198,7 +199,7 @@ class Configuration extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
ipcRenderer.send('set_config_values', {
|
||||
ipcRenderer.send(Constants.IPC_Set_Config_Values, {
|
||||
Directory: this.props.directory,
|
||||
Items: changedItems,
|
||||
StorageType: this.props.storageType,
|
||||
|
||||
@@ -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