Compute the number of unread messages in reducer
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import PropTypes from 'prop-types';
|
||||
import * as stateActions from '../../redux/stateActions';
|
||||
import * as toolTabActions from '../../redux/stateActions';
|
||||
import ParticipantList from '../ParticipantList/ParticipantList';
|
||||
import Chat from '../Chat/Chat';
|
||||
import Settings from '../Settings';
|
||||
@@ -16,7 +16,8 @@ class ToolArea extends React.Component
|
||||
render()
|
||||
{
|
||||
const {
|
||||
toolarea,
|
||||
currentToolTab,
|
||||
unread,
|
||||
setToolTab
|
||||
} = this.props;
|
||||
|
||||
@@ -31,9 +32,11 @@ class ToolArea extends React.Component
|
||||
{
|
||||
setToolTab('chat');
|
||||
}}
|
||||
checked={toolarea.currentToolTab === 'chat'}
|
||||
checked={currentToolTab === 'chat'}
|
||||
/>
|
||||
<label htmlFor='tab-chat'>Chat</label>
|
||||
<label htmlFor='tab-chat'>
|
||||
Chat ({unread} new)
|
||||
</label>
|
||||
|
||||
<div className='tab'>
|
||||
<Chat />
|
||||
@@ -47,7 +50,7 @@ class ToolArea extends React.Component
|
||||
{
|
||||
setToolTab('users');
|
||||
}}
|
||||
checked={toolarea.currentToolTab === 'users'}
|
||||
checked={currentToolTab === 'users'}
|
||||
/>
|
||||
<label htmlFor='tab-users'>Users</label>
|
||||
|
||||
@@ -63,7 +66,7 @@ class ToolArea extends React.Component
|
||||
{
|
||||
setToolTab('settings');
|
||||
}}
|
||||
checked={toolarea.currentToolTab === 'settings'}
|
||||
checked={currentToolTab === 'settings'}
|
||||
/>
|
||||
<label htmlFor='tab-settings'>Settings</label>
|
||||
|
||||
@@ -78,26 +81,19 @@ class ToolArea extends React.Component
|
||||
|
||||
ToolArea.propTypes =
|
||||
{
|
||||
advancedMode : PropTypes.bool,
|
||||
toolarea : PropTypes.object.isRequired,
|
||||
setToolTab : PropTypes.func.isRequired
|
||||
advancedMode : PropTypes.bool,
|
||||
currentToolTab : PropTypes.string.isRequired,
|
||||
setToolTab : PropTypes.func.isRequired,
|
||||
unread : PropTypes.number.isRequired
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) =>
|
||||
{
|
||||
return {
|
||||
toolarea : state.toolarea
|
||||
};
|
||||
};
|
||||
const mapStateToProps = (state) => ({
|
||||
currentToolTab : state.toolarea.currentToolTab,
|
||||
unread : state.toolarea.unread
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
{
|
||||
return {
|
||||
setToolTab : (toolTab) =>
|
||||
{
|
||||
dispatch(stateActions.setToolTab(toolTab));
|
||||
}
|
||||
};
|
||||
const mapDispatchToProps = {
|
||||
setToolTab : toolTabActions.setToolTab
|
||||
};
|
||||
|
||||
const ToolAreaContainer = connect(
|
||||
|
||||
Reference in New Issue
Block a user