Save profile chat

This commit is contained in:
Andrea Maria Piana 2021-11-03 11:31:11 +00:00
parent 54b3689814
commit 7fc812b693
2 changed files with 5 additions and 1 deletions

View file

@ -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

View file

@ -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 {