Skip to content

Commit

Permalink
Merge branch 'dev' into linux-gpu
Browse files Browse the repository at this point in the history
  • Loading branch information
hql287 authored Jan 5, 2018
2 parents 09c1bb7 + 4f76145 commit e10f37c
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 65 deletions.
8 changes: 2 additions & 6 deletions app/App.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Libs
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
const ipc = require('electron').ipcRenderer;
Expand All @@ -19,7 +19,7 @@ import AppUpdate from './components/layout/AppUpdate';
import { AppWrapper } from './components/shared/Layout';

// Components
class App extends Component {
class App extends PureComponent {
constructor(props) {
super(props);
this.changeTab = this.changeTab.bind(this);
Expand Down Expand Up @@ -65,10 +65,6 @@ class App extends Component {
});
}

shouldComponentUpdate(nextProps) {
return this.props !== nextProps;
}

componentWillUnmount() {
ipc.removeAllListeners([
'menu-change-tab',
Expand Down
8 changes: 2 additions & 6 deletions app/components/contacts/Contact.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
// Libs
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';

// Custom Components
import { TR, TD } from '../shared/Table';
import Button from '../shared/Button';

// Component
class Contact extends Component {
class Contact extends PureComponent {
constructor(props) {
super(props);
this.deleteContact = this.deleteContact.bind(this);
this.newInvoice = this.newInvoice.bind(this);
}

shouldComponentUpdate(nextProps) {
return this.props !== nextProps;
}

newInvoice() {
const { newInvoice, contact } = this.props;
newInvoice(contact);
Expand Down
8 changes: 2 additions & 6 deletions app/components/form/ItemsList.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Libs
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';

// Redux
Expand Down Expand Up @@ -58,18 +58,14 @@ const ItemsListDiv = styled.div`
`;

// Component
export class ItemsList extends Component {
export class ItemsList extends PureComponent {
componentDidMount() {
const { rows, boundActionCreators } = this.props;
if (!rows.length) {
boundActionCreators.addItem();
}
}

shouldComponentUpdate(nextProps) {
return this.props !== nextProps;
}

render() {
// Bound Actions
const { addItem, removeItem, updateItem } = this.props.boundActionCreators;
Expand Down
8 changes: 2 additions & 6 deletions app/components/form/Settings.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Libraries
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { isEqual } from 'lodash';

Expand Down Expand Up @@ -79,18 +79,14 @@ import Switch from '../shared/Switch';

// Component

class Settings extends Component {
class Settings extends PureComponent {
constructor(props) {
super(props);
this.isSettingsSaved = this.isSettingsSaved.bind(this);
this.saveAsDefault = this.saveAsDefault.bind(this);
this.handleInputChange = this.handleInputChange.bind(this);
}

shouldComponentUpdate(nextProps) {
return this.props !== nextProps;
}

// Update local state
handleInputChange(event) {
this.props.toggleField(event.target.name);
Expand Down
8 changes: 3 additions & 5 deletions app/components/form/hoc/_withDragNDrop.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
// Libs
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { DragDropContext, Droppable } from 'react-beautiful-dnd';

class DragNDrop extends Component {
class DragNDrop extends PureComponent {
constructor(props) {
super(props);
this.onDragEnd = this.onDragEnd.bind(this);
}
shouldComponentUpdate(nextProps) {
return this.props !== nextProps;
}

onDragEnd(result) {
if (!result.destination) {
return;
Expand Down
8 changes: 2 additions & 6 deletions app/containers/Contacts.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Libs
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { compose } from 'recompose';
import { connect } from 'react-redux';
Expand All @@ -26,7 +26,7 @@ import {
import { getContacts } from '../reducers/ContactsReducer';

// Component
class Contacts extends Component {
class Contacts extends PureComponent {
constructor(props) {
super(props);
this.newInvoice = this.newInvoice.bind(this);
Expand All @@ -41,10 +41,6 @@ class Contacts extends Component {
});
}

shouldComponentUpdate(nextProps) {
return this.props !== nextProps;
}

componentWillUnmount() {
ipc.removeAllListeners('confirmed-delete-contact');
}
Expand Down
9 changes: 2 additions & 7 deletions app/containers/Invoices.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Libs
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { compose } from 'recompose';
import { connect } from 'react-redux';
Expand All @@ -24,7 +24,7 @@ import {
PageContent,
} from '../components/shared/Layout';

class Invoices extends Component {
class Invoices extends PureComponent {
constructor(props) {
super(props);
this.deleteInvoice = this.deleteInvoice.bind(this);
Expand All @@ -41,11 +41,6 @@ class Invoices extends Component {
});
}

// Optimization
shouldComponentUpdate(nextProps) {
return this.props !== nextProps;
}

// Remove all IPC listeners when unmounted
componentWillUnmount() {
ipc.removeAllListeners('confirmed-delete-invoice');
Expand Down
7 changes: 2 additions & 5 deletions preview/components/main/Invoice.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Libraries
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';

// Style
Expand All @@ -25,10 +25,7 @@ import Minimal from '../../templates/minimal';
import Business from '../../templates/business';

// Component
class Invoice extends Component {
shouldComponentUpdate(nextProps) {
return this.props !== nextProps;
}
class Invoice extends PureComponent {

renderTemplate() {
switch (this.props.configs.template) {
Expand Down
8 changes: 2 additions & 6 deletions preview/components/sidebar/AccentColor.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Libs
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { BlockPicker } from 'react-color';
import { Section, Label } from '../shared';
Expand Down Expand Up @@ -48,7 +48,7 @@ const Cover = styled.div`
left: 0px;
`;

class AccentColor extends Component {
class AccentColor extends PureComponent {
constructor(props) {
super(props);
this.state = {
Expand All @@ -63,10 +63,6 @@ class AccentColor extends Component {
this.handleInputChange = this.handleInputChange.bind(this);
}

shouldComponentUpdate(nextProps, nextState) {
return this.state !== nextState || this.props !== nextProps;
}

handleClick() {
this.setState({ showPicker: !this.state.showPicker });
}
Expand Down
8 changes: 2 additions & 6 deletions preview/containers/MainContent.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Libs
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
const ipc = require('electron').ipcRenderer;
Expand Down Expand Up @@ -35,18 +35,14 @@ const Message = styled.p`
// Components
import Invoice from '../components/main/Invoice';

class MainContent extends Component {
class MainContent extends PureComponent {
componentDidMount() {
ipc.on('update-preview', (event, invoiceData) => {
const { dispatch } = this.props;
dispatch(ActionsCreator.updateInvoice(invoiceData));
});
}

shouldComponentUpdate(nextProps) {
return this.props !== nextProps;
}

componentWillUnmount() {
ipc.removeAllListeners(['update-preview']);
}
Expand Down
8 changes: 2 additions & 6 deletions preview/containers/SideBar.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Libs
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
const ipc = require('electron').ipcRenderer;
Expand Down Expand Up @@ -35,7 +35,7 @@ import Toggler from '../components/sidebar/Toggler';
import AccentColor from '../components/sidebar/AccentColor';
import Actions from '../components/sidebar/Actions';

class SideBar extends Component {
class SideBar extends PureComponent {
constructor(props) {
super(props);
this.savePDF = this.savePDF.bind(this);
Expand All @@ -44,10 +44,6 @@ class SideBar extends Component {
this.updateConfigs = this.updateConfigs.bind(this);
}

shouldComponentUpdate(nextProps) {
return this.props !== nextProps;
}

handleInputChange(event) {
const target = event.target;
const value = target.type === 'checkbox' ? target.checked : target.value;
Expand Down

0 comments on commit e10f37c

Please sign in to comment.