Skip to content

Commit

Permalink
Performance optimizations (#19)
Browse files Browse the repository at this point in the history
* refactor: remove unused dependencies

* refactor: remove unused dependencies

* fix(windows): fix hide of undefined

* refactor: update packages
  • Loading branch information
ritz078 authored May 24, 2017
1 parent 2397de5 commit dd96ae3
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 515 deletions.
19 changes: 12 additions & 7 deletions main/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
const { app, BrowserWindow, Menu } = require('electron');
const {
default: installExtension,
REACT_DEVELOPER_TOOLS,
REDUX_DEVTOOLS
} = require('electron-devtools-installer');
const getPort = require('get-port');
const fixPath = require('fix-path');
const dev = require('electron-is-dev');
Expand Down Expand Up @@ -43,7 +38,9 @@ async function createWindow() {
try {
await server(port);
downloadTorrent.init();
app.dock.show();
if (process.platform === 'darwin') {
app.dock.show();
}
} catch (err) {
return;
}
Expand All @@ -53,6 +50,12 @@ async function createWindow() {
Menu.setApplicationMenu(Menu.buildFromTemplate(template));

if (dev) {
const {
default: installExtension,
REACT_DEVELOPER_TOOLS,
REDUX_DEVTOOLS
} = require('electron-devtools-installer');

installExtension(REACT_DEVELOPER_TOOLS);
installExtension(REDUX_DEVTOOLS);

Expand All @@ -79,7 +82,9 @@ app.on('ready', async () => {
});

app.on('window-all-closed', () => {
app.dock.hide();
if (process.platform === 'darwin') {
app.dock.hide();
}
if (process.platform !== 'darwin') {
app.quit();
}
Expand Down
2 changes: 0 additions & 2 deletions main/middleware/helpers/torrentStore.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const WebTorrent = require('webtorrent');
const tempy = require('tempy');

const debug = require('debug')('torrentStore');
const rimraf = require('rimraf');
const parseTorrent = require('parse-torrent');

Expand All @@ -23,7 +22,6 @@ module.exports = {
client.torrents.forEach((torrent) => {
if (torrent.infoHash !== infoHash) {
rimraf(`${BASE_PATH}/${torrent.name}`, () => {
debug(`removed all torrents except ${infoHash}`);
if (cb) {
cb();
}
Expand Down
26 changes: 6 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,11 @@
"homepage": "https://github.com/ritz078/snape#readme",
"dependencies": {
"app-root-path": "^2.0.1",
"bytebuffer": "^5.0.1",
"chai": "^3.5.0",
"chromecasts": "^1.9.0",
"classnames": "^2.2.5",
"cors": "^2.8.3",
"debug": "^2.6.8",
"deep-compare": "^0.0.5",
"downloads-folder": "^1.0.0",
"electron-debug": "^1.1.0",
"electron-devtools-installer": "^2.2.0",
"electron-drag": "^1.2.0",
"electron-is-dev": "^0.1.2",
"electron-lets-move": "^0.0.5",
"electron-unhandled": "^0.2.0",
Expand All @@ -55,7 +49,6 @@
"internal-ip": "^1.2.0",
"is-electron-renderer": "^2.0.1",
"lodash": "^4.17.4",
"mdi": "^1.9.33",
"mime": "^1.3.6",
"next": "^2.4.0",
"next-redux-wrapper": "^1.1.2",
Expand All @@ -65,7 +58,6 @@
"postcss-easy-import": "^2.0.0",
"pretty-bytes": "^4.0.2",
"prop-types": "^15.5.10",
"protobufjs": "^6.7.3",
"pump": "^1.0.2",
"query-string": "^4.3.4",
"range-parser": "^1.2.0",
Expand All @@ -81,7 +73,7 @@
"redux": "^3.6.0",
"redux-create-reducer": "^1.1.1",
"redux-observable": "^0.14.1",
"rimraf": "^2.5.4",
"rimraf": "^2.6.1",
"rxjs": "^5.4.0",
"sinon": "^2.3.1",
"snape-config": "^0.0.1",
Expand All @@ -95,41 +87,35 @@
"window-or-global": "^1.0.1"
},
"devDependencies": {
"autoprefixer": "^7.1.1",
"babel-eslint": "^7.2.3",
"babel-loader": "^7.0.0",
"babel-plugin-styled-components": "^1.1.4",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-wrap-in-js": "^1.1.1",
"babili-webpack-plugin": "^0.1.1",
"colors": "1.1.2",
"css-loader": "^0.28.2",
"cz-conventional-changelog": "^2.0.0",
"devtron": "^1.4.0",
"electron": "^1.6.8",
"electron-builder": "^17.10.0",
"electron-builder-squirrel-windows": "^17.9.0",
"electron-builder": "^18.0.1",
"electron-builder-squirrel-windows": "^18.0.0",
"electron-devtools-installer": "^2.2.0",
"electron-rebuild": "^1.5.11",
"eslint": "^3.19.0",
"eslint-config-airbnb": "^15.0.1",
"eslint-plugin-flowtype": "^2.33.0",
"eslint-plugin-import": "2.2.0",
"eslint-plugin-import": "^2.3.0",
"eslint-plugin-jsx-a11y": "^5.0.3",
"eslint-plugin-react": "^7.0.1",
"extract-text-webpack-plugin": "2.1.0",
"file-loader": "^0.11.1",
"glob": "^7.1.2",
"husky": "^0.13.3",
"less": "^2.7.2",
"less-loader": "^4.0.3",
"lint-staged": "^3.4.2",
"nodemon": "^1.11.0",
"postcss-loader": "^2.0.5",
"prettier-eslint-cli": "^4.0.1",
"raw-loader": "^0.5.1",
"react-addons-test-utils": "^15.5.1",
"rimraf": "2.6.1"
"raw-loader": "^0.5.1"
},
"config": {
"commitizen": {
Expand Down
3 changes: 1 addition & 2 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module.exports = {
plugins: [
require('postcss-easy-import')({prefix: '_'}),
require('autoprefixer')()
require('postcss-easy-import')({ prefix: '_' })
]
}
4 changes: 2 additions & 2 deletions renderer/components/DownloadTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { remote, ipcRenderer } from 'electron';
import styled from 'styled-components';
import deepCompare from 'deep-compare';
import prettyBytes from 'pretty-bytes';
import { isEqual } from 'lodash';
import Description from './Description';
import { showToast } from './Toast';

Expand Down Expand Up @@ -77,7 +77,7 @@ export default class DownloadTile extends Component {

shouldComponentUpdate(nextProps) {
return (
!deepCompare(this.props.downloadData, nextProps.downloadData) ||
!isEqual(this.props.downloadData, nextProps.downloadData) ||
this.props.selectedIndex !== nextProps.selectedIndex
);
}
Expand Down
2 changes: 1 addition & 1 deletion renderer/components/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import NProgress from 'nprogress';
import Router from 'next/router';

import stylesheet from '../styles/index.less';
import MenuBar from './MenuBar';
import MenuBar from './NavBar';
import Controls from './Controls';
import AudioPlayer from './AudioPlayer';

Expand Down
File renamed without changes.
2 changes: 0 additions & 2 deletions renderer/pages/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { ipcRenderer } from 'electron';
import withRedux from 'next-redux-wrapper';
import { isEmpty } from 'lodash';
import { readConfig } from 'snape-config';
import initStore from '../store';
import Layout from '../components/Layout';
import DownloadTile, {
Expand Down
Loading

0 comments on commit dd96ae3

Please sign in to comment.