Skip to content

Commit

Permalink
updates for the breaking changes to remote module
Browse files Browse the repository at this point in the history
  • Loading branch information
davemfish committed Sep 17, 2020
1 parent 42713b1 commit a9621a4
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/components/LoadButton/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { remote } from 'electron'; // eslint-disable-line import/no-extraneous-dependencies
import remote from '@electron/remote';
import PropTypes from 'prop-types';

import Button from 'react-bootstrap/Button';
Expand Down
2 changes: 1 addition & 1 deletion src/components/SaveFileButton/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { remote } from 'electron'; // eslint-disable-line import/no-extraneous-dependencies
import remote from '@electron/remote';
import PropTypes from 'prop-types';

import Button from 'react-bootstrap/Button';
Expand Down
2 changes: 1 addition & 1 deletion src/components/SetupTab/ArgsForm/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { remote } from 'electron'; // eslint-disable-line import/no-extraneous-dependencies
import remote from '@electron/remote';

import Form from 'react-bootstrap/Form';

Expand Down
2 changes: 1 addition & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path';
import { remote } from 'electron'; // eslint-disable-line import/no-extraneous-dependencies
import remote from '@electron/remote';

const USER_DATA = remote.app.getPath('userData');

Expand Down
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { remote, ipcRenderer } = require('electron'); // eslint-disable-line import/no-extraneous-dependencies
const { ipcRenderer } = require('electron'); // eslint-disable-line import/no-extraneous-dependencies
const remote = require('@electron/remote');

const isDevMode = remote.process.argv[2] === '--dev';
if (isDevMode) {
Expand Down Expand Up @@ -51,5 +52,5 @@ ipcRenderer.on('variable-reply', (event, arg) => {
// render the App after receiving any critical data
// from the main process
render(arg.investExe);
})
});
ipcRenderer.send('variable-request', 'ping');
7 changes: 4 additions & 3 deletions src/logger.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
const path = require('path');
const winston = require('winston');
require('winston-daily-rotate-file');
const { app, remote } = require('electron');
const { app } = require('electron');

let userDataPath;
let isDevMode;
if (remote) {
// When this module is imported from render process, access via remote
if (process && process.type === 'renderer') {
// When this module is imported from renderer process, access via remote
const remote = require('@electron/remote');
userDataPath = remote.app.getPath('userData');
isDevMode = remote.process.argv[2] === '--dev';
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require('@electron/remote/main').initialize();

const isDevMode = process.argv[2] === '--dev';
if (isDevMode) {
// in dev mode we can have babel transpile modules on import
Expand Down Expand Up @@ -45,6 +47,7 @@ const createWindow = async () => {
useContentSize: true,
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true,
},
});

Expand Down

0 comments on commit a9621a4

Please sign in to comment.