Support changing the nick by clicking it in MessageInput

This commit is contained in:
Ken-Håvard Lieng 2017-06-21 07:23:07 +02:00
parent 4a74463ae8
commit f174d98107
16 changed files with 335 additions and 134 deletions

View file

@ -123,18 +123,17 @@ export default createReducer(Map(), {
});
},
[actions.socket.NICK](state, action) {
const { server } = action;
[actions.socket.NICK](state, { server, oldNick, newNick }) {
return state.withMutations(s => {
s.get(server).forEach((v, channel) => {
s.updateIn([server, channel, 'users'], users => {
const i = users.findIndex(user => user.nick === action.old);
const i = users.findIndex(user => user.nick === oldNick);
if (i < 0) {
return users;
}
return users.update(i,
user => updateRenderName(user.set('nick', action.new))
user => updateRenderName(user.set('nick', newNick))
).sort(compareUsers);
});
});