dispatch/client/js/containers/Chat.js

90 lines
2.1 KiB
JavaScript
Raw Normal View History

2015-12-28 23:34:32 +00:00
import { bindActionCreators } from 'redux';
import { createStructuredSelector } from 'reselect';
import Chat from 'components/pages/Chat';
import { getSelectedTabTitle } from 'state';
2018-04-05 23:46:22 +00:00
import {
getSelectedChannel,
getSelectedChannelUsers,
part
} from 'state/channels';
import {
getCurrentInputHistoryEntry,
addInputHistory,
resetInputHistory,
incrementInputHistory,
decrementInputHistory
} from 'state/input';
import {
getSelectedMessages,
getHasMoreMessages,
runCommand,
sendMessage,
fetchMessages,
addFetchedMessages
} from 'state/messages';
import { openPrivateChat, closePrivateChat } from 'state/privateChats';
import { getSearch, searchMessages, toggleSearch } from 'state/search';
2018-04-05 23:46:22 +00:00
import {
getCurrentNick,
getCurrentServerStatus,
disconnect,
setNick,
setServerName
} from 'state/servers';
2018-10-15 06:56:17 +00:00
import { getSettings } from 'state/settings';
import { getSelectedTab, select } from 'state/tab';
import { getShowUserList, toggleUserList } from 'state/ui';
import connect from 'utils/connect';
2015-12-28 23:34:32 +00:00
const mapState = createStructuredSelector({
channel: getSelectedChannel,
currentInputHistoryEntry: getCurrentInputHistoryEntry,
2017-05-02 21:21:25 +00:00
hasMoreMessages: getHasMoreMessages,
messages: getSelectedMessages,
nick: getCurrentNick,
search: getSearch,
showUserList: getShowUserList,
status: getCurrentServerStatus,
tab: getSelectedTab,
title: getSelectedTabTitle,
2018-10-15 06:56:17 +00:00
users: getSelectedChannelUsers,
coloredNicks: state => getSettings(state).coloredNicks
2016-02-16 21:43:25 +00:00
});
2015-12-28 23:34:32 +00:00
const mapDispatch = dispatch => ({
2018-04-05 23:46:22 +00:00
...bindActionCreators(
{
addFetchedMessages,
closePrivateChat,
disconnect,
fetchMessages,
openPrivateChat,
part,
runCommand,
searchMessages,
select,
sendMessage,
setNick,
setServerName,
toggleSearch,
toggleUserList
},
dispatch
),
2018-04-05 23:46:22 +00:00
inputActions: bindActionCreators(
{
add: addInputHistory,
reset: resetInputHistory,
increment: incrementInputHistory,
decrement: decrementInputHistory
},
dispatch
)
});
2015-12-28 23:34:32 +00:00
2018-05-28 01:16:05 +00:00
export default connect(
mapState,
mapDispatch
)(Chat);