From e0ca9d5d8c748e34c01ca757d28c891c83849edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ken-H=C3=A5vard=20Lieng?= Date: Mon, 22 Jun 2020 17:22:10 +0200 Subject: [PATCH] Fix lastMessages map init in LoadUsers() --- storage/user.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/storage/user.go b/storage/user.go index 3ce2e5ce..277da199 100644 --- a/storage/user.go +++ b/storage/user.go @@ -85,9 +85,11 @@ func LoadUsers(store Store) ([]*User, error) { for _, channel := range channels { messages, _, err := user.LastMessages(channel.Network, channel.Name, 1) if err == nil && len(messages) == 1 { - user.lastMessages[channel.Network] = map[string]*Message{ - channel.Name: &messages[0], + if _, ok := user.lastMessages[channel.Network]; !ok { + user.lastMessages[channel.Network] = map[string]*Message{} } + + user.lastMessages[channel.Network][channel.Name] = &messages[0] } } }