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 => { socket.on('join', data => {
const state = getState(); const state = getState();
const { server, channel } = state.tab.selected; const { server, channel } = state.tab.selected;
const { nick } = state.servers.get(server); if (server && channel) {
const [joinedChannel] = data.channels; const { nick } = state.servers.get(server);
if (channel && const [joinedChannel] = data.channels;
server === data.server && if (server === data.server &&
nick === data.user && nick === data.user &&
channel !== joinedChannel && channel !== joinedChannel &&
normalizeChannel(channel) === normalizeChannel(joinedChannel)) { normalizeChannel(channel) === normalizeChannel(joinedChannel)) {
dispatch(select(server, joinedChannel)); dispatch(select(server, joinedChannel));
}
} }
}); });