Fix race condition with NICK and QUIT when multiple dispatch users are in the same channel

This commit is contained in:
Ken-Håvard Lieng 2017-04-11 03:49:52 +02:00
parent 3393b1b706
commit 18651c1a10
8 changed files with 145 additions and 138 deletions

View file

@ -104,15 +104,15 @@ export default createReducer(Map(), {
},
[actions.SOCKET_NICK](state, action) {
const { server, channels } = action;
const { server } = action;
return state.withMutations(s => {
channels.forEach(channel => {
s.updateIn([server, channel, 'users'], users => {
const i = users.findIndex(user => user.nick === action.old);
return users.update(i, user =>
updateRenderName(user.set('nick', action.new))
).sort(compareUsers);
});
s.get(server).forEach((v, channel) => {
s.updateIn([server, channel, 'users'], users =>
users.update(
users.findIndex(user => user.nick === action.old),
user => updateRenderName(user.set('nick', action.new))
).sort(compareUsers)
);
});
});
},