dispatch/client/js/containers/Chat.js

89 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';
2019-01-25 02:57:58 +00:00
import { openModal } from 'state/modals';
import { openPrivateChat, closePrivateChat } from 'state/privateChats';
import { getSearch, searchMessages, toggleSearch } from 'state/search';
2018-04-05 23:46:22 +00:00
import {
getCurrentNick,
2020-06-15 08:58:51 +00:00
getCurrentNetworkError,
2018-04-05 23:46:22 +00:00
disconnect,
setNick,
2020-06-15 08:58:51 +00:00
setNetworkName
} from 'state/networks';
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,
2020-06-15 08:58:51 +00:00
error: getCurrentNetworkError,
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,
2019-01-25 02:57:58 +00:00
openModal,
2018-04-05 23:46:22 +00:00
openPrivateChat,
part,
runCommand,
searchMessages,
select,
sendMessage,
setNick,
2020-06-15 08:58:51 +00:00
setNetworkName,
2018-04-05 23:46:22 +00:00
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
2020-04-30 05:54:30 +00:00
export default connect(mapState, mapDispatch)(Chat);