Properly check if a channel is selected in socket.on('join')

This commit is contained in:
Ken-Håvard Lieng 2016-01-13 20:22:41 +01:00
parent 58caacd269
commit d2284551de
2 changed files with 18 additions and 17 deletions

File diff suppressed because one or more lines are too long

View File

@ -23,14 +23,15 @@ export default function handleSocket(socket, { dispatch, getState }) {
socket.on('join', data => {
const state = getState();
const { server, channel } = state.tab.selected;
const { nick } = state.servers.get(server);
const [joinedChannel] = data.channels;
if (channel &&
server === data.server &&
nick === data.user &&
channel !== joinedChannel &&
normalizeChannel(channel) === normalizeChannel(joinedChannel)) {
dispatch(select(server, joinedChannel));
if (server && channel) {
const { nick } = state.servers.get(server);
const [joinedChannel] = data.channels;
if (server === data.server &&
nick === data.user &&
channel !== joinedChannel &&
normalizeChannel(channel) === normalizeChannel(joinedChannel)) {
dispatch(select(server, joinedChannel));
}
}
});