Fix potential threading issue.

This commit is contained in:
Chris Rhodes 2016-04-19 16:00:12 -07:00
parent f654ec2a42
commit a9bed749a1

View file

@ -260,8 +260,6 @@ func (s *State) ChannelRemove(channel *Channel) error {
return err
}
delete(s.channelMap, channel.ID)
if channel.IsPrivate {
s.Lock()
defer s.Unlock()
@ -269,7 +267,7 @@ func (s *State) ChannelRemove(channel *Channel) error {
for i, c := range s.PrivateChannels {
if c.ID == channel.ID {
s.PrivateChannels = append(s.PrivateChannels[:i], s.PrivateChannels[i+1:]...)
return nil
break
}
}
} else {
@ -284,11 +282,13 @@ func (s *State) ChannelRemove(channel *Channel) error {
for i, c := range guild.Channels {
if c.ID == channel.ID {
guild.Channels = append(guild.Channels[:i], guild.Channels[i+1:]...)
return nil
break
}
}
}
delete(s.channelMap, channel.ID)
return nil
}