Wait for server comfirmation before updating nick
This commit is contained in:
parent
1739b15eaa
commit
b2e3e995ce
File diff suppressed because one or more lines are too long
@ -27,9 +27,12 @@ export default createReducer(Map(), {
|
||||
return state.delete(action.server);
|
||||
},
|
||||
|
||||
[actions.SET_NICK](state, action) {
|
||||
const { server, nick } = action;
|
||||
return state.update(server, s => s.set('nick', nick));
|
||||
[actions.SOCKET_NICK](state, action) {
|
||||
const { server, old } = action;
|
||||
if (!old || old === state.get(server).nick) {
|
||||
return state.update(server, s => s.set('nick', action.new));
|
||||
}
|
||||
return state;
|
||||
},
|
||||
|
||||
[actions.SOCKET_SERVERS](state, action) {
|
||||
|
@ -191,15 +191,12 @@ func (c *Client) recv() {
|
||||
}
|
||||
|
||||
case ReplyWelcome:
|
||||
c.setNick(msg.Params[0])
|
||||
c.once.Do(c.ready.Done)
|
||||
|
||||
case ErrNicknameInUse:
|
||||
if c.HandleNickInUse != nil {
|
||||
newNick := c.HandleNickInUse(msg.Params[1])
|
||||
// Set the nick here aswell incase this happens during registration
|
||||
// since there will be no NICK message to confirm it then
|
||||
c.setNick(newNick)
|
||||
go c.writeNick(newNick)
|
||||
go c.writeNick(c.HandleNickInUse(msg.Params[1]))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,9 +13,7 @@ import (
|
||||
func createNickInUseHandler(i *irc.Client, session *Session) func(string) string {
|
||||
return func(nick string) string {
|
||||
newNick := nick + "_"
|
||||
|
||||
session.print(i.Host, "Nickname", nick, "is already in use, using", newNick, "instead")
|
||||
go session.user.SetNick(newNick, i.Host)
|
||||
|
||||
return newNick
|
||||
}
|
||||
|
@ -150,6 +150,15 @@ func (i *ircHandler) quit(msg *irc.Message) {
|
||||
}
|
||||
|
||||
func (i *ircHandler) info(msg *irc.Message) {
|
||||
if msg.Command == irc.ReplyWelcome {
|
||||
i.session.sendJSON("nick", Nick{
|
||||
Server: i.client.Host,
|
||||
New: msg.Params[0],
|
||||
})
|
||||
|
||||
go i.session.user.SetNick(msg.Params[0], i.client.Host)
|
||||
}
|
||||
|
||||
i.session.sendJSON("pm", Chat{
|
||||
Server: i.client.Host,
|
||||
From: msg.Nick,
|
||||
|
Loading…
Reference in New Issue
Block a user