From 7fc812b693aebd2e564d5d6134cc9a58ee9cd0e2 Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Wed, 3 Nov 2021 11:31:11 +0000 Subject: [PATCH] Save profile chat --- protocol/messenger_chats.go | 2 +- protocol/messenger_contacts.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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 {