Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Commit

Permalink
#2473 optimize header and inbox
Browse files Browse the repository at this point in the history
  • Loading branch information
siemiatj committed Dec 16, 2019
1 parent 87c932e commit b2c7bfb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
20 changes: 11 additions & 9 deletions src/components/header/Header.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import counterpart from 'counterpart';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import { connect } from 'react-redux';
import { push } from 'react-router-redux';
import classnames from 'classnames';
Expand Down Expand Up @@ -33,7 +33,7 @@ import UserDropdown from './UserDropdown';
* @module Header
* @extends Component
*/
class Header extends Component {
class Header extends PureComponent {
state = {
isSubheaderShow: false,
isSideListShow: false,
Expand Down Expand Up @@ -127,8 +127,12 @@ class Header extends Component {
* @summary ToDo: Describe the method
* @param {object} state
*/
handleInboxOpen = state => {
this.setState({ isInboxOpen: !!state });
closeInbox = () => {
this.setState({ isInboxOpen: false });
};

openInbox = () => {
this.setState({ isInboxOpen: true });
};

/**
Expand Down Expand Up @@ -683,9 +687,7 @@ class Header extends Component {
'header-item-open': isInboxOpen,
}
)}
onClick={() =>
this.closeOverlays('', () => this.handleInboxOpen(true))
}
onClick={() => this.closeOverlays('', this.openInbox)}
onMouseEnter={() =>
this.toggleTooltip(keymap.OPEN_INBOX_MENU)
}
Expand All @@ -711,8 +713,8 @@ class Header extends Component {
<Inbox
ref={this.inboxRef}
open={isInboxOpen}
close={this.handleInboxOpen}
onFocus={() => this.handleInboxOpen(true)}
close={this.closeInbox}
onFocus={this.openInbox}
disableOnClickOutside={true}
inbox={inbox}
/>
Expand Down
10 changes: 3 additions & 7 deletions src/components/inbox/Inbox.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import counterpart from 'counterpart';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import onClickOutside from 'react-onclickoutside';
import { withRouter } from 'react-router';
import { connect } from 'react-redux';
Expand All @@ -19,11 +19,7 @@ import InboxItem from './InboxItem';
* @module Inbox
* @extends Component
*/
class Inbox extends Component {
constructor(props) {
super(props);
}

class Inbox extends PureComponent {
/**
* @method handleClick
* @summary ToDo: Describe the method
Expand Down Expand Up @@ -222,7 +218,7 @@ const routerInbox = withRouter(
* @todo Write the documentation
*/
const addClickOutsideHandler = Child => {
return class WithClickOutsideHandler extends Component {
return class WithClickOutsideHandler extends PureComponent {
static propTypes = {
close: PropTypes.func,
};
Expand Down
10 changes: 2 additions & 8 deletions src/components/inbox/InboxItem.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import counterpart from 'counterpart';
import Moment from 'moment';
import React, { Component } from 'react';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';

/**
* @file Class based component.
* @module InboxItem
* @extends Component
*/
class InboxItem extends Component {
constructor(props) {
super(props);
}

export default class InboxItem extends PureComponent {
/**
* @method renderIconFromTarget
* @summary ToDo: Describe the method
Expand Down Expand Up @@ -137,5 +133,3 @@ InboxItem.propTypes = {
onClick: PropTypes.any,
onDelete: PropTypes.any,
};

export default InboxItem;

0 comments on commit b2c7bfb

Please sign in to comment.