Select channel when joining through UI

This commit is contained in:
Ken-Håvard Lieng 2020-06-21 05:33:02 +02:00
parent ca23b3ded8
commit b9f52a8761
7 changed files with 81 additions and 73 deletions

File diff suppressed because one or more lines are too long

View File

@ -40,7 +40,6 @@ export default createCommandMiddleware(COMMAND, {
return error('Bad channel name');
}
dispatch(join([channel], network));
dispatch(select(network, channel));
} else {
return error('Missing channel');
}

View File

@ -5,7 +5,6 @@ import { FiUsers, FiX } from 'react-icons/fi';
import useModal from 'components/modals/useModal';
import Button from 'components/ui/Button';
import { join } from 'state/channels';
import { select } from 'state/tab';
import { searchChannels } from 'state/channelSearch';
import { linkify } from 'utils';
@ -91,7 +90,6 @@ const AddChannel = () => {
}
dispatch(join([channel], network));
dispatch(select(network, channel));
}
}
};

View File

@ -238,7 +238,7 @@ export default withFormik({
select(values.host);
if (channels.length > 0) {
join(channels, values.host);
join(channels, values.host, false);
}
localStorage.lastNick = values.nick;

View File

@ -235,11 +235,12 @@ export default createReducer(
}
);
export function join(channels, network) {
export function join(channels, network, selectFirst = true) {
return {
type: actions.JOIN,
channels,
network,
selectFirst,
socket: {
type: 'join',
data: { channels, network }

View File

@ -41,8 +41,8 @@ export default createReducer(
},
[actions.ADD_MESSAGE](state, { message }) {
const { network, from } = message;
if (from !== network && !isChannel(from)) {
const { network, from, to } = message;
if (!to && from.indexOf('.') === -1 && !isChannel(from)) {
open(state, network, from);
}
},

View File

@ -23,6 +23,16 @@ export const getSelectedTab = state => state.tab.selected;
export default createReducer(initialState, {
[actions.SELECT_TAB]: selectTab,
[actions.JOIN](state, { network, channels, selectFirst }) {
if (selectFirst) {
state.selected = {
network,
name: channels[0]
};
state.history.push(state.selected);
}
},
[actions.PART](state, action) {
state.history = state.history.filter(
tab =>