diff --git a/protocol/messenger_chats.go b/protocol/messenger_chats.go index 5cc38b2e6..d2e03ab32 100644 --- a/protocol/messenger_chats.go +++ b/protocol/messenger_chats.go @@ -406,7 +406,7 @@ func (m *Messenger) saveChat(chat *Chat) error { if err != nil { return err } - // TODO(samyoul) remove storing of an updated reference pointer? + // We store the chat has it might not have been in the store in the first place m.allChats.Store(chat.ID, chat) return nil diff --git a/protocol/messenger_contacts.go b/protocol/messenger_contacts.go index e9ae7ac54..0ca8fdf90 100644 --- a/protocol/messenger_contacts.go +++ b/protocol/messenger_contacts.go @@ -85,6 +85,9 @@ func (m *Messenger) AddContact(ctx context.Context, request *requests.AddContact if err != nil { return nil, err } + if err := m.saveChat(profileChat); err != nil { + return nil, err + } // Fetch contact code publicKey, err := contact.PublicKey() @@ -285,6 +288,7 @@ func (m *Messenger) BlockContact(contact *Contact) ([]*Chat, error) { m.allChats.Store(chat.ID, chat) } m.allChats.Delete(contact.ID) + m.allChats.Delete(buildProfileChatID(contact.ID)) err = m.syncContact(context.Background(), contact) if err != nil {