Show current nick in MessageInput

This commit is contained in:
Ken-Håvard Lieng 2017-05-15 22:51:21 +02:00
parent d3a0a21338
commit 2328cfa940
5 changed files with 53 additions and 24 deletions

File diff suppressed because one or more lines are too long

View File

@ -443,13 +443,27 @@ i[class^="icon-"]:before, i[class*=" icon-"]:before {
right: 0; right: 0;
height: 50px; height: 50px;
z-index: 1; z-index: 1;
display: flex;
border-top: 1px solid #DDD;
background: #FFF;
}
.message-input-nick {
margin: 10px;
line-height: 30px;
height: 30px;
padding: 0 10px;
background: #6BB758;
color: #FFF;
font-family: Montserrat, sans-serif;
margin-right: 0;
} }
.message-input { .message-input {
flex: 1;
width: 100%; width: 100%;
height: 100%; height: 100%;
padding: 15px; padding: 0 15px;
border-top: 1px solid #DDD;
} }
.userlist { .userlist {

View File

@ -37,8 +37,10 @@ export default class MessageInput extends PureComponent {
}; };
render() { render() {
const { nick } = this.props;
return ( return (
<div className="message-input-wrap"> <div className="message-input-wrap">
<span className="message-input-nick">{nick}</span>
<input <input
className="message-input" className="message-input"
type="text" type="text"

View File

@ -18,6 +18,7 @@ import { toggleUserList } from '../actions/ui';
import * as inputHistoryActions from '../actions/inputHistory'; import * as inputHistoryActions from '../actions/inputHistory';
import { getSelectedTab } from '../reducers/tab'; import { getSelectedTab } from '../reducers/tab';
import { getSelectedMessages } from '../reducers/messages'; import { getSelectedMessages } from '../reducers/messages';
import { getCurrentNick } from '../reducers/servers';
class Chat extends PureComponent { class Chat extends PureComponent {
handleSearch = phrase => { handleSearch = phrase => {
@ -38,7 +39,7 @@ class Chat extends PureComponent {
render() { render() {
const { title, tab, channel, search, history, const { title, tab, channel, search, history,
messages, hasMoreMessages, users, showUserList, inputActions } = this.props; messages, hasMoreMessages, users, showUserList, nick, inputActions } = this.props;
let chatClass; let chatClass;
if (tab.isChannel()) { if (tab.isChannel()) {
@ -76,6 +77,7 @@ class Chat extends PureComponent {
tab={tab} tab={tab}
channel={channel} channel={channel}
history={history} history={history}
nick={nick}
runCommand={this.props.runCommand} runCommand={this.props.runCommand}
sendMessage={this.props.sendMessage} sendMessage={this.props.sendMessage}
{...inputActions} {...inputActions}
@ -138,7 +140,8 @@ const mapStateToProps = createStructuredSelector({
users: usersSelector, users: usersSelector,
showUserList: showUserListSelector, showUserList: showUserListSelector,
search: searchSelector, search: searchSelector,
history: historySelector history: historySelector,
nick: getCurrentNick
}); });
function mapDispatchToProps(dispatch) { function mapDispatchToProps(dispatch) {

View File

@ -1,6 +1,8 @@
import { Map, Record } from 'immutable'; import { Map, Record } from 'immutable';
import { createSelector } from 'reselect';
import createReducer from '../util/createReducer'; import createReducer from '../util/createReducer';
import * as actions from '../actions'; import * as actions from '../actions';
import { getSelectedTab } from './tab';
const Server = Record({ const Server = Record({
nick: null, nick: null,
@ -8,6 +10,14 @@ const Server = Record({
connected: false connected: false
}); });
export const getServers = state => state.servers;
export const getCurrentNick = createSelector(
getServers,
getSelectedTab,
(servers, tab) => servers.getIn([tab.server, 'nick'], '')
);
export default createReducer(Map(), { export default createReducer(Map(), {
[actions.CONNECT](state, action) { [actions.CONNECT](state, action) {
const { host, nick, options } = action; const { host, nick, options } = action;