Handle kick, rename server to network
This commit is contained in:
parent
a33157ff84
commit
6985dd16da
65 changed files with 2650 additions and 2179 deletions
|
@ -15,7 +15,7 @@ const App = ({
|
|||
connected,
|
||||
tab,
|
||||
channels,
|
||||
servers,
|
||||
networks,
|
||||
privateChats,
|
||||
showTabList,
|
||||
select,
|
||||
|
@ -62,7 +62,7 @@ const App = ({
|
|||
<TabList
|
||||
tab={tab}
|
||||
channels={channels}
|
||||
servers={servers}
|
||||
networks={networks}
|
||||
privateChats={privateChats}
|
||||
showTabList={showTabList}
|
||||
select={select}
|
||||
|
|
|
@ -7,7 +7,7 @@ import TabListItem from 'containers/TabListItem';
|
|||
import { count } from 'utils';
|
||||
|
||||
export default class TabList extends PureComponent {
|
||||
handleTabClick = (server, target) => this.props.select(server, target);
|
||||
handleTabClick = (network, target) => this.props.select(network, target);
|
||||
|
||||
handleConnectClick = () => this.props.push('/connect');
|
||||
|
||||
|
@ -17,7 +17,7 @@ export default class TabList extends PureComponent {
|
|||
const {
|
||||
tab,
|
||||
channels,
|
||||
servers,
|
||||
networks,
|
||||
privateChats,
|
||||
showTabList,
|
||||
openModal
|
||||
|
@ -28,21 +28,21 @@ export default class TabList extends PureComponent {
|
|||
'off-canvas': showTabList
|
||||
});
|
||||
|
||||
channels.forEach(server => {
|
||||
const { address } = server;
|
||||
const srv = servers[address];
|
||||
channels.forEach(network => {
|
||||
const { address } = network;
|
||||
const srv = networks[address];
|
||||
tabs.push(
|
||||
<TabListItem
|
||||
key={address}
|
||||
server={address}
|
||||
network={address}
|
||||
content={srv.name}
|
||||
selected={tab.server === address && !tab.name}
|
||||
connected={srv.status.connected}
|
||||
selected={tab.network === address && !tab.name}
|
||||
connected={srv.connected}
|
||||
onClick={this.handleTabClick}
|
||||
/>
|
||||
);
|
||||
|
||||
const chanCount = count(server.channels, c => c.joined);
|
||||
const chanCount = count(network.channels, c => c.joined);
|
||||
const chanLimit =
|
||||
get(srv.features, ['CHANLIMIT', '#'], 0) || srv.features.MAXCHANNELS;
|
||||
|
||||
|
@ -68,15 +68,15 @@ export default class TabList extends PureComponent {
|
|||
</div>
|
||||
);
|
||||
|
||||
server.channels.forEach(({ name, joined }) =>
|
||||
network.channels.forEach(({ name, joined }) =>
|
||||
tabs.push(
|
||||
<TabListItem
|
||||
key={address + name}
|
||||
server={address}
|
||||
network={address}
|
||||
target={name}
|
||||
content={name}
|
||||
joined={joined}
|
||||
selected={tab.server === address && tab.name === name}
|
||||
selected={tab.network === address && tab.name === name}
|
||||
onClick={this.handleTabClick}
|
||||
/>
|
||||
)
|
||||
|
@ -99,10 +99,10 @@ export default class TabList extends PureComponent {
|
|||
tabs.push(
|
||||
<TabListItem
|
||||
key={address + nick}
|
||||
server={address}
|
||||
network={address}
|
||||
target={nick}
|
||||
content={nick}
|
||||
selected={tab.server === address && tab.name === nick}
|
||||
selected={tab.network === address && tab.name === nick}
|
||||
onClick={this.handleTabClick}
|
||||
/>
|
||||
)
|
||||
|
|
|
@ -4,7 +4,7 @@ import classnames from 'classnames';
|
|||
const TabListItem = ({
|
||||
target,
|
||||
content,
|
||||
server,
|
||||
network,
|
||||
selected,
|
||||
connected,
|
||||
joined,
|
||||
|
@ -12,7 +12,7 @@ const TabListItem = ({
|
|||
onClick
|
||||
}) => {
|
||||
const className = classnames({
|
||||
'tab-server': !target,
|
||||
'tab-network': !target,
|
||||
success: !target && connected,
|
||||
error: (!target && !connected) || (!joined && error),
|
||||
disabled: !!target && !error && joined === false,
|
||||
|
@ -20,7 +20,7 @@ const TabListItem = ({
|
|||
});
|
||||
|
||||
return (
|
||||
<p className={className} onClick={() => onClick(server, target)}>
|
||||
<p className={className} onClick={() => onClick(network, target)}>
|
||||
<span className="tab-content">{content}</span>
|
||||
</p>
|
||||
);
|
||||
|
|
|
@ -9,10 +9,10 @@ import { select } from 'state/tab';
|
|||
import { searchChannels } from 'state/channelSearch';
|
||||
import { linkify } from 'utils';
|
||||
|
||||
const Channel = memo(({ server, name, topic, userCount, joined }) => {
|
||||
const Channel = memo(({ network, name, topic, userCount, joined }) => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const handleClick = () => dispatch(join([name], server));
|
||||
const handleClick = () => dispatch(join([name], network));
|
||||
|
||||
return (
|
||||
<div className="modal-channel-result">
|
||||
|
@ -40,7 +40,7 @@ const Channel = memo(({ server, name, topic, userCount, joined }) => {
|
|||
});
|
||||
|
||||
const AddChannel = () => {
|
||||
const [modal, server, closeModal] = useModal('channel');
|
||||
const [modal, network, closeModal] = useModal('channel');
|
||||
|
||||
const channels = useSelector(state => state.channels);
|
||||
const search = useSelector(state => state.channelSearch);
|
||||
|
@ -53,7 +53,7 @@ const AddChannel = () => {
|
|||
|
||||
useEffect(() => {
|
||||
if (modal.isOpen) {
|
||||
dispatch(searchChannels(server, ''));
|
||||
dispatch(searchChannels(network, ''));
|
||||
setTimeout(() => inputEl.current.focus(), 0);
|
||||
} else {
|
||||
prevSearch.current = '';
|
||||
|
@ -74,7 +74,7 @@ const AddChannel = () => {
|
|||
|
||||
if (nextQ !== prevSearch.current) {
|
||||
prevSearch.current = nextQ;
|
||||
dispatch(searchChannels(server, nextQ));
|
||||
dispatch(searchChannels(network, nextQ));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -90,14 +90,14 @@ const AddChannel = () => {
|
|||
channel = `#${channel}`;
|
||||
}
|
||||
|
||||
dispatch(join([channel], server));
|
||||
dispatch(select(server, channel));
|
||||
dispatch(join([channel], network));
|
||||
dispatch(select(network, channel));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleLoadMore = () =>
|
||||
dispatch(searchChannels(server, q, search.results.length));
|
||||
dispatch(searchChannels(network, q, search.results.length));
|
||||
|
||||
let hasMore = !search.end;
|
||||
if (hasMore) {
|
||||
|
@ -131,9 +131,9 @@ const AddChannel = () => {
|
|||
<div ref={resultsEl} className="modal-channel-results">
|
||||
{search.results.map(channel => (
|
||||
<Channel
|
||||
key={`${server} ${channel.name}`}
|
||||
server={server}
|
||||
joined={channels[server]?.[channel.name]?.joined}
|
||||
key={`${network} ${channel.name}`}
|
||||
network={network}
|
||||
joined={channels[network]?.[channel.name]?.joined}
|
||||
{...channel}
|
||||
/>
|
||||
))}
|
||||
|
|
|
@ -11,40 +11,40 @@ export default class Chat extends Component {
|
|||
const { tab, part, closePrivateChat, disconnect } = this.props;
|
||||
|
||||
if (isChannel(tab)) {
|
||||
part([tab.name], tab.server);
|
||||
part([tab.name], tab.network);
|
||||
} else if (tab.name) {
|
||||
closePrivateChat(tab.server, tab.name);
|
||||
closePrivateChat(tab.network, tab.name);
|
||||
} else {
|
||||
disconnect(tab.server);
|
||||
disconnect(tab.network);
|
||||
}
|
||||
};
|
||||
|
||||
handleSearch = phrase => {
|
||||
const { tab, searchMessages } = this.props;
|
||||
if (isChannel(tab)) {
|
||||
searchMessages(tab.server, tab.name, phrase);
|
||||
searchMessages(tab.network, tab.name, phrase);
|
||||
}
|
||||
};
|
||||
|
||||
handleNickClick = nick => {
|
||||
const { tab, openPrivateChat, select } = this.props;
|
||||
openPrivateChat(tab.server, nick);
|
||||
select(tab.server, nick);
|
||||
openPrivateChat(tab.network, nick);
|
||||
select(tab.network, nick);
|
||||
};
|
||||
|
||||
handleTitleChange = title => {
|
||||
const { setServerName, tab } = this.props;
|
||||
setServerName(title, tab.server);
|
||||
const { setNetworkName, tab } = this.props;
|
||||
setNetworkName(title, tab.network);
|
||||
};
|
||||
|
||||
handleNickChange = nick => {
|
||||
const { setNick, tab } = this.props;
|
||||
setNick(nick, tab.server, true);
|
||||
setNick(nick, tab.network, true);
|
||||
};
|
||||
|
||||
handleNickEditDone = nick => {
|
||||
const { setNick, tab } = this.props;
|
||||
setNick(nick, tab.server);
|
||||
setNick(nick, tab.network);
|
||||
};
|
||||
|
||||
render() {
|
||||
|
@ -57,7 +57,7 @@ export default class Chat extends Component {
|
|||
nick,
|
||||
search,
|
||||
showUserList,
|
||||
status,
|
||||
error,
|
||||
tab,
|
||||
title,
|
||||
users,
|
||||
|
@ -77,14 +77,14 @@ export default class Chat extends Component {
|
|||
} else if (tab.name) {
|
||||
chatClass = 'chat-private';
|
||||
} else {
|
||||
chatClass = 'chat-server';
|
||||
chatClass = 'chat-network';
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={chatClass}>
|
||||
<ChatTitle
|
||||
channel={channel}
|
||||
status={status}
|
||||
error={error}
|
||||
tab={tab}
|
||||
title={title}
|
||||
openModal={openModal}
|
||||
|
|
|
@ -3,11 +3,11 @@ import { FiUsers, FiSearch, FiX } from 'react-icons/fi';
|
|||
import Navicon from 'components/ui/Navicon';
|
||||
import Button from 'components/ui/Button';
|
||||
import Editable from 'components/ui/Editable';
|
||||
import { isValidServerName } from 'state/servers';
|
||||
import { isValidNetworkName } from 'state/networks';
|
||||
import { isChannel } from 'utils';
|
||||
|
||||
const ChatTitle = ({
|
||||
status,
|
||||
error,
|
||||
title,
|
||||
tab,
|
||||
channel,
|
||||
|
@ -26,11 +26,9 @@ const ChatTitle = ({
|
|||
closeTitle = 'Disconnect';
|
||||
}
|
||||
|
||||
let serverError = null;
|
||||
if (!tab.name && status.error) {
|
||||
serverError = (
|
||||
<span className="chat-topic error">Error: {status.error}</span>
|
||||
);
|
||||
let networkError = null;
|
||||
if (!tab.name && error) {
|
||||
networkError = <span className="chat-topic error">Error: {error}</span>;
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -41,13 +39,13 @@ const ChatTitle = ({
|
|||
className="chat-title"
|
||||
editable={!tab.name}
|
||||
value={title}
|
||||
validate={isValidServerName}
|
||||
validate={isValidNetworkName}
|
||||
onChange={onTitleChange}
|
||||
>
|
||||
<span className="chat-title">{title}</span>
|
||||
</Editable>
|
||||
<div className="chat-topic-wrap">
|
||||
{channel && channel.topic && (
|
||||
{channel?.topic && (
|
||||
<span
|
||||
className="chat-topic"
|
||||
onClick={() => openModal('topic', channel.name)}
|
||||
|
@ -55,7 +53,7 @@ const ChatTitle = ({
|
|||
{channel.topic}
|
||||
</span>
|
||||
)}
|
||||
{serverError}
|
||||
{networkError}
|
||||
</div>
|
||||
{tab.name && (
|
||||
<Button
|
||||
|
@ -80,7 +78,7 @@ const ChatTitle = ({
|
|||
</div>
|
||||
<div className="userlist-bar">
|
||||
<FiUsers />
|
||||
{channel && channel.users.length}
|
||||
{channel?.users.length}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -36,7 +36,7 @@ export default class MessageBox extends PureComponent {
|
|||
addMore = debounce(() => {
|
||||
const { tab, onAddMore } = this.props;
|
||||
this.ready = true;
|
||||
onAddMore(tab.server, tab.name);
|
||||
onAddMore(tab.network, tab.name);
|
||||
}, scrollbackDebounce);
|
||||
|
||||
constructor(props) {
|
||||
|
@ -130,7 +130,7 @@ export default class MessageBox extends PureComponent {
|
|||
|
||||
updateScrollKey = () => {
|
||||
const { tab } = this.props;
|
||||
this.scrollKey = `msg:${tab.server}:${tab.name}`;
|
||||
this.scrollKey = `msg:${tab.network}:${tab.name}`;
|
||||
return this.scrollKey;
|
||||
};
|
||||
|
||||
|
@ -222,7 +222,7 @@ export default class MessageBox extends PureComponent {
|
|||
if (this.shouldAdd) {
|
||||
const { tab, onAddMore } = this.props;
|
||||
this.shouldAdd = false;
|
||||
onAddMore(tab.server, tab.name);
|
||||
onAddMore(tab.network, tab.name);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@ const MessageInput = ({
|
|||
const handleKey = e => {
|
||||
if (e.key === 'Enter' && e.target.value) {
|
||||
if (e.target.value[0] === '/') {
|
||||
onCommand(e.target.value, tab.name, tab.server);
|
||||
onCommand(e.target.value, tab.name, tab.network);
|
||||
} else if (tab.name) {
|
||||
onMessage(e.target.value, tab.name, tab.server);
|
||||
onMessage(e.target.value, tab.name, tab.network);
|
||||
}
|
||||
|
||||
add(e.target.value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue