Fix lastMessages map init in LoadUsers()

This commit is contained in:
Ken-Håvard Lieng 2020-06-22 17:22:10 +02:00
parent 972f568a00
commit e0ca9d5d8c

View File

@ -85,9 +85,11 @@ func LoadUsers(store Store) ([]*User, error) {
for _, channel := range channels { for _, channel := range channels {
messages, _, err := user.LastMessages(channel.Network, channel.Name, 1) messages, _, err := user.LastMessages(channel.Network, channel.Name, 1)
if err == nil && len(messages) == 1 { if err == nil && len(messages) == 1 {
user.lastMessages[channel.Network] = map[string]*Message{ if _, ok := user.lastMessages[channel.Network]; !ok {
channel.Name: &messages[0], user.lastMessages[channel.Network] = map[string]*Message{}
} }
user.lastMessages[channel.Network][channel.Name] = &messages[0]
} }
} }
} }