Select channel when joining through UI
This commit is contained in:
parent
ca23b3ded8
commit
b9f52a8761
File diff suppressed because one or more lines are too long
@ -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');
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -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;
|
||||
|
@ -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 }
|
||||
|
@ -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);
|
||||
}
|
||||
},
|
||||
|
@ -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 =>
|
||||
|
Loading…
Reference in New Issue
Block a user