From 583cecc6616fb4893a3a450dd808b9d75685f885 Mon Sep 17 00:00:00 2001 From: SurajRathod Date: Sat, 6 Jun 2020 17:46:30 +0530 Subject: [PATCH 1/2] selective import --- src/config.js | 6 +- src/crash-reporter.js | 4 +- src/main/announcement.js | 4 +- src/main/dialog.js | 8 +-- src/main/handlers.js | 3 +- src/main/index.js | 5 +- src/main/ipc.js | 68 +++++++++---------- src/main/log.js | 4 +- src/main/menu.js | 8 +-- src/main/power-save-blocker.js | 10 +-- src/main/shell.js | 10 +-- src/main/shortcuts.js | 14 ++-- src/main/squirrel-win32.js | 4 +- src/main/tray.js | 8 +-- src/main/updater.js | 16 ++--- src/main/user-tasks.js | 4 +- src/main/windows/about.js | 4 +- src/main/windows/main.js | 8 +-- src/main/windows/webtorrent.js | 6 +- src/renderer/components/path-selector.js | 4 +- .../components/unsupported-media-modal.js | 4 +- .../components/update-available-modal.js | 4 +- .../controllers/playback-controller.js | 4 +- src/renderer/controllers/prefs-controller.js | 2 +- .../controllers/subtitles-controller.js | 4 +- .../controllers/torrent-controller.js | 2 +- .../controllers/torrent-list-controller.js | 36 +++++----- src/renderer/lib/telemetry.js | 4 +- src/renderer/webtorrent.js | 67 +++++++++--------- 29 files changed, 147 insertions(+), 178 deletions(-) diff --git a/src/config.js b/src/config.js index c55e73fa..e94dafe7 100644 --- a/src/config.js +++ b/src/config.js @@ -1,6 +1,6 @@ const appConfig = require('application-config')('WebTorrent') const path = require('path') -const electron = require('electron') +const { app, remote } = require('electron') const arch = require('arch') const APP_NAME = 'WebTorrent' @@ -126,10 +126,10 @@ function getPath (key) { return '' } else if (process.type === 'renderer') { // Electron renderer process - return electron.remote.app.getPath(key) + return remote.app.getPath(key) } else { // Electron main process - return electron.app.getPath(key) + return app.getPath(key) } } diff --git a/src/crash-reporter.js b/src/crash-reporter.js index 8fd2ac15..e5baec00 100644 --- a/src/crash-reporter.js +++ b/src/crash-reporter.js @@ -4,9 +4,9 @@ module.exports = { function init () { const config = require('./config') - const electron = require('electron') + const { crashReporter } = require('electron') - electron.crashReporter.start({ + crashReporter.start({ companyName: config.APP_NAME, productName: config.APP_NAME, submitURL: config.CRASH_REPORT_URL diff --git a/src/main/announcement.js b/src/main/announcement.js index 6ef429b1..faf3c5dc 100644 --- a/src/main/announcement.js +++ b/src/main/announcement.js @@ -2,7 +2,7 @@ module.exports = { init } -const electron = require('electron') +const { dialog } = require('electron') const config = require('../config') const log = require('./log') @@ -44,7 +44,7 @@ function onResponse (err, res, data) { } } - electron.dialog.showMessageBox({ + dialog.showMessageBox({ type: 'info', buttons: ['OK'], title: data.title, diff --git a/src/main/dialog.js b/src/main/dialog.js index 1ccb3dfd..5a510bb5 100644 --- a/src/main/dialog.js +++ b/src/main/dialog.js @@ -6,7 +6,7 @@ module.exports = { openFiles } -const electron = require('electron') +const { dialog } = require('electron') const log = require('./log') const windows = require('./windows') @@ -61,7 +61,7 @@ function openFiles () { properties: ['openFile'] } setTitle(opts.title) - const selectedPaths = electron.dialog.showOpenDialogSync(windows.main.win, opts) + const selectedPaths = dialog.showOpenDialogSync(windows.main.win, opts) resetTitle() if (!Array.isArray(selectedPaths)) return windows.main.dispatch('onOpen', selectedPaths) @@ -79,7 +79,7 @@ function openTorrentFile () { properties: ['openFile', 'multiSelections'] } setTitle(opts.title) - const selectedPaths = electron.dialog.showOpenDialogSync(windows.main.win, opts) + const selectedPaths = dialog.showOpenDialogSync(windows.main.win, opts) resetTitle() if (!Array.isArray(selectedPaths)) return selectedPaths.forEach(function (selectedPath) { @@ -114,7 +114,7 @@ function resetTitle () { */ function showOpenSeed (opts) { setTitle(opts.title) - const selectedPaths = electron.dialog.showOpenDialogSync(windows.main.win, opts) + const selectedPaths = dialog.showOpenDialogSync(windows.main.win, opts) resetTitle() if (!Array.isArray(selectedPaths)) return windows.main.dispatch('showCreateTorrent', selectedPaths) diff --git a/src/main/handlers.js b/src/main/handlers.js index dcc004d8..20c905a0 100644 --- a/src/main/handlers.js +++ b/src/main/handlers.js @@ -25,8 +25,7 @@ function uninstall () { } function installDarwin () { - const electron = require('electron') - const app = electron.app + const { app } = require('electron') // On Mac, only protocols that are listed in `Info.plist` can be set as the // default handler at runtime. diff --git a/src/main/index.js b/src/main/index.js index d670caba..fca30743 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -1,7 +1,6 @@ console.time('init') -const electron = require('electron') -const app = electron.app +const { app, ipcMain } = require('electron') const parallel = require('run-parallel') @@ -64,8 +63,6 @@ function init () { app.setPath('temp', path.join(config.CONFIG_PATH, 'Temp')) } - const ipcMain = electron.ipcMain - let isReady = false // app ready, windows can be created app.ipcReady = false // main window has finished loading and IPC is ready app.isQuitting = false diff --git a/src/main/ipc.js b/src/main/ipc.js index 216b7e5f..b5608e98 100644 --- a/src/main/ipc.js +++ b/src/main/ipc.js @@ -3,9 +3,7 @@ module.exports = { setModule } -const electron = require('electron') - -const app = electron.app +const { app, ipcMain } = require('electron') const log = require('./log') const menu = require('./menu') @@ -23,14 +21,12 @@ function setModule (name, module) { } function init () { - const ipc = electron.ipcMain - - ipc.once('ipcReady', function (e) { + ipcMain.once('ipcReady', function (e) { app.ipcReady = true app.emit('ipcReady') }) - ipc.once('ipcReadyWebTorrent', function (e) { + ipcMain.once('ipcReadyWebTorrent', function (e) { app.ipcReadyWebTorrent = true log('sending %d queued messages from the main win to the webtorrent window', messageQueueMainToWebTorrent.length) @@ -44,11 +40,11 @@ function init () { * Dialog */ - ipc.on('openTorrentFile', () => { + ipcMain.on('openTorrentFile', () => { const dialog = require('./dialog') dialog.openTorrentFile() }) - ipc.on('openFiles', () => { + ipcMain.on('openFiles', () => { const dialog = require('./dialog') dialog.openFiles() }) @@ -57,11 +53,11 @@ function init () { * Dock */ - ipc.on('setBadge', (e, ...args) => { + ipcMain.on('setBadge', (e, ...args) => { const dock = require('./dock') dock.setBadge(...args) }) - ipc.on('downloadFinished', (e, ...args) => { + ipcMain.on('downloadFinished', (e, ...args) => { const dock = require('./dock') dock.downloadFinished(...args) }) @@ -70,7 +66,7 @@ function init () { * Player Events */ - ipc.on('onPlayerOpen', function () { + ipcMain.on('onPlayerOpen', function () { const powerSaveBlocker = require('./power-save-blocker') const shortcuts = require('./shortcuts') const thumbar = require('./thumbar') @@ -81,14 +77,14 @@ function init () { thumbar.enable() }) - ipc.on('onPlayerUpdate', function (e, ...args) { + ipcMain.on('onPlayerUpdate', function (e, ...args) { const thumbar = require('./thumbar') menu.onPlayerUpdate(...args) thumbar.onPlayerUpdate(...args) }) - ipc.on('onPlayerClose', function () { + ipcMain.on('onPlayerClose', function () { const powerSaveBlocker = require('./power-save-blocker') const shortcuts = require('./shortcuts') const thumbar = require('./thumbar') @@ -99,7 +95,7 @@ function init () { thumbar.disable() }) - ipc.on('onPlayerPlay', function () { + ipcMain.on('onPlayerPlay', function () { const powerSaveBlocker = require('./power-save-blocker') const thumbar = require('./thumbar') @@ -107,7 +103,7 @@ function init () { thumbar.onPlayerPlay() }) - ipc.on('onPlayerPause', function () { + ipcMain.on('onPlayerPause', function () { const powerSaveBlocker = require('./power-save-blocker') const thumbar = require('./thumbar') @@ -119,7 +115,7 @@ function init () { * Folder Watcher Events */ - ipc.on('startFolderWatcher', function () { + ipcMain.on('startFolderWatcher', function () { if (!modules.folderWatcher) { log('IPC ERR: folderWatcher module is not defined.') return @@ -128,7 +124,7 @@ function init () { modules.folderWatcher.start() }) - ipc.on('stopFolderWatcher', function () { + ipcMain.on('stopFolderWatcher', function () { if (!modules.folderWatcher) { log('IPC ERR: folderWatcher module is not defined.') return @@ -141,15 +137,15 @@ function init () { * Shell */ - ipc.on('openItem', (e, ...args) => { + ipcMain.on('openItem', (e, ...args) => { const shell = require('./shell') shell.openItem(...args) }) - ipc.on('showItemInFolder', (e, ...args) => { + ipcMain.on('showItemInFolder', (e, ...args) => { const shell = require('./shell') shell.showItemInFolder(...args) }) - ipc.on('moveItemToTrash', (e, ...args) => { + ipcMain.on('moveItemToTrash', (e, ...args) => { const shell = require('./shell') shell.moveItemToTrash(...args) }) @@ -158,7 +154,7 @@ function init () { * File handlers */ - ipc.on('setDefaultFileHandler', (e, flag) => { + ipcMain.on('setDefaultFileHandler', (e, flag) => { const handlers = require('./handlers') if (flag) handlers.install() @@ -169,7 +165,7 @@ function init () { * Auto start on login */ - ipc.on('setStartup', (e, flag) => { + ipcMain.on('setStartup', (e, flag) => { const startup = require('./startup') if (flag) startup.install() @@ -182,19 +178,19 @@ function init () { const main = windows.main - ipc.on('setAspectRatio', (e, ...args) => main.setAspectRatio(...args)) - ipc.on('setBounds', (e, ...args) => main.setBounds(...args)) - ipc.on('setProgress', (e, ...args) => main.setProgress(...args)) - ipc.on('setTitle', (e, ...args) => main.setTitle(...args)) - ipc.on('show', () => main.show()) - ipc.on('toggleFullScreen', (e, ...args) => main.toggleFullScreen(...args)) - ipc.on('setAllowNav', (e, ...args) => menu.setAllowNav(...args)) + ipcMain.on('setAspectRatio', (e, ...args) => main.setAspectRatio(...args)) + ipcMain.on('setBounds', (e, ...args) => main.setBounds(...args)) + ipcMain.on('setProgress', (e, ...args) => main.setProgress(...args)) + ipcMain.on('setTitle', (e, ...args) => main.setTitle(...args)) + ipcMain.on('show', () => main.show()) + ipcMain.on('toggleFullScreen', (e, ...args) => main.toggleFullScreen(...args)) + ipcMain.on('setAllowNav', (e, ...args) => menu.setAllowNav(...args)) /** * External Media Player */ - ipc.on('checkForExternalPlayer', function (e, path) { + ipcMain.on('checkForExternalPlayer', function (e, path) { const externalPlayer = require('./external-player') externalPlayer.checkInstall(path, function (err) { @@ -202,7 +198,7 @@ function init () { }) }) - ipc.on('openExternalPlayer', (e, ...args) => { + ipcMain.on('openExternalPlayer', (e, ...args) => { const externalPlayer = require('./external-player') const thumbar = require('./thumbar') @@ -211,7 +207,7 @@ function init () { externalPlayer.spawn(...args) }) - ipc.on('quitExternalPlayer', () => { + ipcMain.on('quitExternalPlayer', () => { const externalPlayer = require('./external-player') externalPlayer.kill() }) @@ -220,8 +216,8 @@ function init () { * Message passing */ - const oldEmit = ipc.emit - ipc.emit = function (name, e, ...args) { + const oldEmit = ipcMain.emit + ipcMain.emit = function (name, e, ...args) { // Relay messages between the main window and the WebTorrent hidden window if (name.startsWith('wt-') && !app.isQuitting) { if (e.sender.browserWindowOptions.title === 'webtorrent-hidden-window') { @@ -244,6 +240,6 @@ function init () { } // Emit all other events normally - oldEmit.call(ipc, name, e, ...args) + oldEmit.call(ipcMain, name, e, ...args) } } diff --git a/src/main/log.js b/src/main/log.js index 9510e353..ac0aa36b 100644 --- a/src/main/log.js +++ b/src/main/log.js @@ -8,11 +8,9 @@ module.exports.error = error * where they can be viewed in Developer Tools. */ -const electron = require('electron') +const { app } = require('electron') const windows = require('./windows') -const app = electron.app - function log (...args) { if (app.ipcReady) { windows.main.send('log', ...args) diff --git a/src/main/menu.js b/src/main/menu.js index b8f1c691..970cb7ff 100644 --- a/src/main/menu.js +++ b/src/main/menu.js @@ -8,9 +8,7 @@ module.exports = { onToggleFullScreen } -const electron = require('electron') - -const app = electron.app +const { app, Menu } = require('electron') const config = require('../config') const windows = require('./windows') @@ -18,8 +16,8 @@ const windows = require('./windows') let menu = null function init () { - menu = electron.Menu.buildFromTemplate(getMenuTemplate()) - electron.Menu.setApplicationMenu(menu) + menu = Menu.buildFromTemplate(getMenuTemplate()) + Menu.setApplicationMenu(menu) } function togglePlaybackControls (flag) { diff --git a/src/main/power-save-blocker.js b/src/main/power-save-blocker.js index 9756c6f7..79c01691 100644 --- a/src/main/power-save-blocker.js +++ b/src/main/power-save-blocker.js @@ -3,7 +3,7 @@ module.exports = { disable } -const electron = require('electron') +const { powerSaveBlocker } = require('electron') const log = require('./log') let blockId = 0 @@ -13,11 +13,11 @@ let blockId = 0 * display. */ function enable () { - if (electron.powerSaveBlocker.isStarted(blockId)) { + if (powerSaveBlocker.isStarted(blockId)) { // If a power saver block already exists, do nothing. return } - blockId = electron.powerSaveBlocker.start('prevent-display-sleep') + blockId = powerSaveBlocker.start('prevent-display-sleep') log(`powerSaveBlocker.enable: ${blockId}`) } @@ -25,10 +25,10 @@ function enable () { * Stop blocking the system from entering low-power mode. */ function disable () { - if (!electron.powerSaveBlocker.isStarted(blockId)) { + if (!powerSaveBlocker.isStarted(blockId)) { // If a power saver block does not exist, do nothing. return } - electron.powerSaveBlocker.stop(blockId) + powerSaveBlocker.stop(blockId) log(`powerSaveBlocker.disable: ${blockId}`) } diff --git a/src/main/shell.js b/src/main/shell.js index cd133fe6..e7b396d6 100644 --- a/src/main/shell.js +++ b/src/main/shell.js @@ -5,7 +5,7 @@ module.exports = { moveItemToTrash } -const electron = require('electron') +const { shell } = require('electron') const log = require('./log') /** @@ -13,7 +13,7 @@ const log = require('./log') */ function openExternal (url) { log(`openExternal: ${url}`) - electron.shell.openExternal(url) + shell.openExternal(url) } /** @@ -21,7 +21,7 @@ function openExternal (url) { */ function openItem (path) { log(`openItem: ${path}`) - electron.shell.openItem(path) + shell.openItem(path) } /** @@ -29,7 +29,7 @@ function openItem (path) { */ function showItemInFolder (path) { log(`showItemInFolder: ${path}`) - electron.shell.showItemInFolder(path) + shell.showItemInFolder(path) } /** @@ -37,5 +37,5 @@ function showItemInFolder (path) { */ function moveItemToTrash (path) { log(`moveItemToTrash: ${path}`) - electron.shell.moveItemToTrash(path) + shell.moveItemToTrash(path) } diff --git a/src/main/shortcuts.js b/src/main/shortcuts.js index eb045cc9..51bcf3bd 100644 --- a/src/main/shortcuts.js +++ b/src/main/shortcuts.js @@ -3,20 +3,20 @@ module.exports = { enable } -const electron = require('electron') +const { globalShortcut } = require('electron') const windows = require('./windows') function enable () { // Register play/pause media key, available on some keyboards. - electron.globalShortcut.register( + globalShortcut.register( 'MediaPlayPause', () => windows.main.dispatch('playPause') ) - electron.globalShortcut.register( + globalShortcut.register( 'MediaNextTrack', () => windows.main.dispatch('nextTrack') ) - electron.globalShortcut.register( + globalShortcut.register( 'MediaPreviousTrack', () => windows.main.dispatch('previousTrack') ) @@ -24,7 +24,7 @@ function enable () { function disable () { // Return the media key to the OS, so other apps can use it. - electron.globalShortcut.unregister('MediaPlayPause') - electron.globalShortcut.unregister('MediaNextTrack') - electron.globalShortcut.unregister('MediaPreviousTrack') + globalShortcut.unregister('MediaPlayPause') + globalShortcut.unregister('MediaNextTrack') + globalShortcut.unregister('MediaPreviousTrack') } diff --git a/src/main/squirrel-win32.js b/src/main/squirrel-win32.js index 24488bea..32a950c4 100644 --- a/src/main/squirrel-win32.js +++ b/src/main/squirrel-win32.js @@ -3,13 +3,11 @@ module.exports = { } const cp = require('child_process') -const electron = require('electron') +const { app } = require('electron') const fs = require('fs') const os = require('os') const path = require('path') -const app = electron.app - const handlers = require('./handlers') const EXE_NAME = path.basename(process.execPath) diff --git a/src/main/tray.js b/src/main/tray.js index 889d1c86..08579a24 100644 --- a/src/main/tray.js +++ b/src/main/tray.js @@ -4,9 +4,7 @@ module.exports = { setWindowFocus } -const electron = require('electron') - -const app = electron.app +const { app, Tray, Menu } = require('electron') const config = require('../config') const windows = require('./windows') @@ -67,7 +65,7 @@ function checkLinuxTraySupport (cb) { } function createTray () { - tray = new electron.Tray(getIconPath()) + tray = new Tray(getIconPath()) // On Windows, left click opens the app, right click opens the context menu. // On Linux, any click (left or right) opens the context menu. @@ -78,7 +76,7 @@ function createTray () { } function updateTrayMenu () { - const contextMenu = electron.Menu.buildFromTemplate(getMenuTemplate()) + const contextMenu = Menu.buildFromTemplate(getMenuTemplate()) tray.setContextMenu(contextMenu) } diff --git a/src/main/updater.js b/src/main/updater.js index f54d8599..f0d1da8a 100644 --- a/src/main/updater.js +++ b/src/main/updater.js @@ -2,7 +2,7 @@ module.exports = { init } -const electron = require('electron') +const { autoUpdater } = require('electron') const get = require('simple-get') const config = require('../config') @@ -47,31 +47,31 @@ function onResponse (err, res, data) { } function initDarwinWin32 () { - electron.autoUpdater.on( + autoUpdater.on( 'error', (err) => log.error(`Update error: ${err.message}`) ) - electron.autoUpdater.on( + autoUpdater.on( 'checking-for-update', () => log('Checking for update') ) - electron.autoUpdater.on( + autoUpdater.on( 'update-available', () => log('Update available') ) - electron.autoUpdater.on( + autoUpdater.on( 'update-not-available', () => log('No update available') ) - electron.autoUpdater.on( + autoUpdater.on( 'update-downloaded', (e, notes, name, date, url) => log(`Update downloaded: ${name}: ${url}`) ) - electron.autoUpdater.setFeedURL({ url: AUTO_UPDATE_URL }) - electron.autoUpdater.checkForUpdates() + autoUpdater.setFeedURL({ url: AUTO_UPDATE_URL }) + autoUpdater.checkForUpdates() } diff --git a/src/main/user-tasks.js b/src/main/user-tasks.js index a3c6ab54..2458731c 100644 --- a/src/main/user-tasks.js +++ b/src/main/user-tasks.js @@ -2,9 +2,7 @@ module.exports = { init } -const electron = require('electron') - -const app = electron.app +const { app } = require('electron') /** * Add a user task menu to the app icon on right-click. (Windows) diff --git a/src/main/windows/about.js b/src/main/windows/about.js index 52c3a1c3..ce9381b3 100644 --- a/src/main/windows/about.js +++ b/src/main/windows/about.js @@ -4,14 +4,14 @@ const about = module.exports = { } const config = require('../../config') -const electron = require('electron') +const { BrowserWindow } = require('electron') function init () { if (about.win) { return about.win.show() } - const win = about.win = new electron.BrowserWindow({ + const win = about.win = new BrowserWindow({ backgroundColor: '#ECECEC', center: true, fullscreen: false, diff --git a/src/main/windows/main.js b/src/main/windows/main.js index 10967bff..adb26f8c 100644 --- a/src/main/windows/main.js +++ b/src/main/windows/main.js @@ -14,11 +14,9 @@ const main = module.exports = { win: null } -const electron = require('electron') +const { app, BrowserWindow, screen } = require('electron') const debounce = require('debounce') -const app = electron.app - const config = require('../../config') const log = require('../log') const menu = require('../menu') @@ -30,7 +28,7 @@ function init (state, options) { const initialBounds = Object.assign(config.WINDOW_INITIAL_BOUNDS, state.saved.bounds) - const win = main.win = new electron.BrowserWindow({ + const win = main.win = new BrowserWindow({ backgroundColor: '#282828', darkTheme: true, // Forces dark theme (GTK+3) height: initialBounds.height, @@ -160,7 +158,7 @@ function setBounds (bounds, maximize) { log(`setBounds: setting bounds to ${JSON.stringify(bounds)}`) if (bounds.x === null && bounds.y === null) { // X and Y not specified? By default, center on current screen - const scr = electron.screen.getDisplayMatching(main.win.getBounds()) + const scr = screen.getDisplayMatching(main.win.getBounds()) bounds.x = Math.round(scr.bounds.x + (scr.bounds.width / 2) - (bounds.width / 2)) bounds.y = Math.round(scr.bounds.y + (scr.bounds.height / 2) - (bounds.height / 2)) log(`setBounds: centered to ${JSON.stringify(bounds)}`) diff --git a/src/main/windows/webtorrent.js b/src/main/windows/webtorrent.js index dfb723f7..aa6aaada 100644 --- a/src/main/windows/webtorrent.js +++ b/src/main/windows/webtorrent.js @@ -6,12 +6,12 @@ const webtorrent = module.exports = { win: null } -const electron = require('electron') +const { app, BrowserWindow } = require('electron') const config = require('../../config') function init () { - const win = webtorrent.win = new electron.BrowserWindow({ + const win = webtorrent.win = new BrowserWindow({ backgroundColor: '#1E1E1E', center: true, fullscreen: false, @@ -35,7 +35,7 @@ function init () { // Prevent killing the WebTorrent process win.on('close', function (e) { - if (electron.app.isQuitting) { + if (app.isQuitting) { return } e.preventDefault() diff --git a/src/renderer/components/path-selector.js b/src/renderer/components/path-selector.js index 7db52eac..77f6120d 100644 --- a/src/renderer/components/path-selector.js +++ b/src/renderer/components/path-selector.js @@ -1,12 +1,10 @@ const path = require('path') const colors = require('material-ui/styles/colors') -const electron = require('electron') +const { remote } = require('electron') const React = require('react') const PropTypes = require('prop-types') -const remote = electron.remote - const RaisedButton = require('material-ui/RaisedButton').default const TextField = require('material-ui/TextField').default diff --git a/src/renderer/components/unsupported-media-modal.js b/src/renderer/components/unsupported-media-modal.js index 2562f510..0e750d72 100644 --- a/src/renderer/components/unsupported-media-modal.js +++ b/src/renderer/components/unsupported-media-modal.js @@ -1,5 +1,5 @@ const React = require('react') -const electron = require('electron') +const { shell } = require('electron') const ModalOKCancel = require('./modal-ok-cancel') const { dispatcher } = require('../lib/dispatcher') @@ -36,7 +36,7 @@ module.exports = class UnsupportedMediaModal extends React.Component { } onInstall () { - electron.shell.openExternal('http://www.videolan.org/vlc/') + shell.openExternal('http://www.videolan.org/vlc/') // TODO: dcposch send a dispatch rather than modifying state directly const state = this.props.state diff --git a/src/renderer/components/update-available-modal.js b/src/renderer/components/update-available-modal.js index d62e9b05..914bb39f 100644 --- a/src/renderer/components/update-available-modal.js +++ b/src/renderer/components/update-available-modal.js @@ -1,5 +1,5 @@ const React = require('react') -const electron = require('electron') +const { shell } = require('electron') const ModalOKCancel = require('./modal-ok-cancel') const { dispatch } = require('../lib/dispatcher') @@ -25,7 +25,7 @@ module.exports = class UpdateAvailableModal extends React.Component { function handleShow () { // TODO: use the GitHub urls from config.js - electron.shell.openExternal('https://github.com/webtorrent/webtorrent-desktop/releases') + shell.openExternal('https://github.com/webtorrent/webtorrent-desktop/releases') dispatch('exitModal') } diff --git a/src/renderer/controllers/playback-controller.js b/src/renderer/controllers/playback-controller.js index 413ccd2d..5761a2e5 100644 --- a/src/renderer/controllers/playback-controller.js +++ b/src/renderer/controllers/playback-controller.js @@ -1,4 +1,4 @@ -const electron = require('electron') +const { ipcRenderer } = require('electron') const path = require('path') const Cast = require('../lib/cast') @@ -11,8 +11,6 @@ const TorrentSummary = require('../lib/torrent-summary') const Playlist = require('../lib/playlist') const State = require('../lib/state') -const ipcRenderer = electron.ipcRenderer - // Controls playback of torrents and files within torrents // both local (