Colocate reducers, actions and selectors

This commit is contained in:
Ken-Håvard Lieng 2017-05-26 08:20:00 +02:00
parent 1e7d4c3fe4
commit 889e3b88b7
53 changed files with 1031 additions and 914 deletions

View file

@ -6,8 +6,8 @@ export default class MessageInput extends PureComponent {
};
handleKey = e => {
const { tab, runCommand, sendMessage, addInputHistory, incrementInputHistory,
decrementInputHistory, resetInputHistory, history } = this.props;
const { tab, runCommand, sendMessage,
add, reset, increment, decrement, currentHistoryEntry } = this.props;
if (e.key === 'Enter' && e.target.value) {
if (e.target.value[0] === '/') {
@ -16,17 +16,17 @@ export default class MessageInput extends PureComponent {
sendMessage(e.target.value, tab.name, tab.server);
}
addInputHistory(e.target.value);
resetInputHistory();
add(e.target.value);
reset();
this.setState({ value: '' });
} else if (e.key === 'ArrowUp') {
e.preventDefault();
incrementInputHistory();
increment();
} else if (e.key === 'ArrowDown') {
decrementInputHistory();
} else if (history) {
decrement();
} else if (currentHistoryEntry) {
this.setState({ value: e.target.value });
resetInputHistory();
reset();
}
};
@ -35,14 +35,14 @@ export default class MessageInput extends PureComponent {
};
render() {
const { nick } = this.props;
const { nick, currentHistoryEntry } = this.props;
return (
<div className="message-input-wrap">
<span className="message-input-nick">{nick}</span>
<input
className="message-input"
type="text"
value={this.props.history || this.state.value}
value={currentHistoryEntry || this.state.value}
onKeyDown={this.handleKey}
onChange={this.handleChange}
/>

View file

@ -1,6 +1,6 @@
import React, { PureComponent } from 'react';
import { connect } from 'react-redux';
import { toggleMenu } from '../actions/ui';
import { toggleMenu } from '../state/ui';
class Navicon extends PureComponent {
render() {

View file

@ -35,7 +35,7 @@ export default class TabList extends PureComponent {
));
if (privateChats.has(address) && privateChats.get(address).size > 0) {
tabs.push(<div className="tab-label">Private messages</div>);
tabs.push(<div key={`${address}-pm}`} className="tab-label">Private messages</div>);
privateChats.get(address).forEach(nick => tabs.push(
<TabListItem