Skip to content

Commit

Permalink
refactor: Modularized ipc constants
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkoelle committed May 22, 2021
1 parent 16b3a14 commit 3b0533b
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function Routes() {
showModal,
unsavedChanges,
]);
useEffect(BackupEffect(workspacePath, saveBackups), [
useEffect(BackupEffect(workspacePath, saveBackups.enabled), [
saveBackups,
workspacePath,
]);
Expand Down
2 changes: 0 additions & 2 deletions app/constants/ipc.ts → app/constants/AutoUpdaterIPC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ export const DOWNLOAD_UPDATE_PROGRESS = 'DOWNLOAD_UPDATE_PROGRESS';
export const DOWNLOAD_UPDATE_SUCCESS = 'DOWNLOAD_UPDATE_SUCCESS';
export const DOWNLOAD_UPDATE_FAILURE = 'DOWNLOAD_UPDATE_FAILURE';
export const QUIT_AND_INSTALL_UPDATE = 'QUIT_AND_INSTALL_UPDATE';
export const REQUEST_FILE_PATH = 'REQUEST_FILE_PATH';
export const RECEIVE_FILE_PATH = 'RECEIVE_FILE_PATH';
2 changes: 2 additions & 0 deletions app/constants/OpenFileIPC.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const REQUEST_FILE_PATH = 'REQUEST_FILE_PATH';
export const RECEIVE_FILE_PATH = 'RECEIVE_FILE_PATH';
4 changes: 2 additions & 2 deletions app/effects/CheckForUpdatesEffect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { UpdateInfo } from 'electron-updater';
import {
CHECK_FOR_UPDATE_PENDING,
CHECK_FOR_UPDATE_SUCCESS,
REQUEST_FILE_PATH,
} from '../constants/ipc';
} from '../constants/AutoUpdaterIPC';
import { REQUEST_FILE_PATH } from '../constants/OpenFileIPC';
import UpdaterModal from '../modals/UpdaterModal';
import { version as currentAppVersion } from '../package.json';

Expand Down
2 changes: 1 addition & 1 deletion app/effects/LoadNewFileEffect.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ipcRenderer } from 'electron';
import * as Path from 'path';
import { RECEIVE_FILE_PATH } from '../constants/ipc';
import { RECEIVE_FILE_PATH } from '../constants/OpenFileIPC';
import ConfirmationDialog from '../dialogs/ConfirmationDialog';
import UnsavedChangesDialog from '../dialogs/UnsavedChangesDialog';
import { workspaceSetPath } from '../features/workspace/workspaceSlice';
Expand Down
2 changes: 1 addition & 1 deletion app/effects/RequestFilePathEffect.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ipcRenderer } from 'electron';
import { REQUEST_FILE_PATH } from '../constants/ipc';
import { REQUEST_FILE_PATH } from '../constants/OpenFileIPC';

const RequestFilePathEffect = () => {
return () => {
Expand Down
6 changes: 3 additions & 3 deletions app/main.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import 'regenerator-runtime/runtime';
import path from 'path';
import { app, BrowserWindow, ipcMain } from 'electron';
import MenuBuilder from './menu';
import * as IPCConstants from './constants/ipc';
import AppUpdater from './updater';
import Backup from './backup';
import Exporter from './exporter';
import Importer from './importer';
import AutoCorrection from './autocorrection';
import { RECEIVE_FILE_PATH, REQUEST_FILE_PATH } from './constants/OpenFileIPC';

let mainWindow: BrowserWindow | null = null;
let file = '';
Expand Down Expand Up @@ -113,7 +113,7 @@ const openWithFileHandler = (argv: string[]) => {
if (mainWindow.isMinimized()) mainWindow.restore();
mainWindow.focus();
if (arg) {
mainWindow.webContents.send(IPCConstants.RECEIVE_FILE_PATH, arg);
mainWindow.webContents.send(RECEIVE_FILE_PATH, arg);
}
}
};
Expand All @@ -122,7 +122,7 @@ const openWithFileHandler = (argv: string[]) => {
* Add event listeners...
*/

ipcMain.on(IPCConstants.REQUEST_FILE_PATH, () => {
ipcMain.on(REQUEST_FILE_PATH, () => {
if (process.platform === 'win32') {
openWithFileHandler(process.argv);
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/modals/UpdaterModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { ipcRenderer, remote, shell } from 'electron';
import { UpdateInfo } from 'electron-updater';
import { useDispatch } from 'react-redux';
import { version as currentAppVersion } from '../package.json';
import * as IPCConstants from '../constants/ipc';
import * as IPCConstants from '../constants/AutoUpdaterIPC';
import { saveAllCorrections } from '../utils/FileAccess';
import { ModalProps } from './ModalProvider';
import CircularProgressWithLabel from '../components/CircularProgressWithLabel';
Expand Down
2 changes: 1 addition & 1 deletion app/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'fs';
import path from 'path';
import { ipcMain } from 'electron';
import { autoUpdater, UpdateCheckResult } from 'electron-updater';
import * as IPCConstants from './constants/ipc';
import * as IPCConstants from './constants/AutoUpdaterIPC';

export default class AppUpdater {
constructor() {
Expand Down

0 comments on commit 3b0533b

Please sign in to comment.