diff --git a/lib/src/services/api/client2client/contact.c2c.dart b/lib/src/services/api/client2client/contact.c2c.dart index cc699ec..ed09723 100644 --- a/lib/src/services/api/client2client/contact.c2c.dart +++ b/lib/src/services/api/client2client/contact.c2c.dart @@ -93,7 +93,7 @@ Future handleContactUpdate( switch (contactUpdate.type) { case EncryptedContent_ContactUpdate_Type.REQUEST: Log.info('Got a contact update request from $fromUserId'); - await notifyContactsAboutProfileChange(onlyToContact: fromUserId); + await sendContactMyProfileData(fromUserId); case EncryptedContent_ContactUpdate_Type.UPDATE: Log.info('Got a contact update $fromUserId'); diff --git a/lib/src/services/api/messages.dart b/lib/src/services/api/messages.dart index d083505..c1e2afd 100644 --- a/lib/src/services/api/messages.dart +++ b/lib/src/services/api/messages.dart @@ -289,26 +289,18 @@ Future notifyContactAboutOpeningMessage( await updateLastMessageId(contactId, biggestMessageId); } -Future notifyContactsAboutProfileChange({int? onlyToContact}) async { - if (gUser.avatarSvg == null) return; - +Future sendContactMyProfileData(int contactId) async { + List? avatarSvgCompressed; + if (gUser.avatarSvg != null) { + avatarSvgCompressed = gzip.encode(utf8.encode(gUser.avatarSvg!)); + } final encryptedContent = pb.EncryptedContent( contactUpdate: pb.EncryptedContent_ContactUpdate( type: pb.EncryptedContent_ContactUpdate_Type.UPDATE, - avatarSvgCompressed: gzip.encode(utf8.encode(gUser.avatarSvg!)), + avatarSvgCompressed: avatarSvgCompressed, displayName: gUser.displayName, username: gUser.username, ), ); - - if (onlyToContact != null) { - await sendCipherText(onlyToContact, encryptedContent); - return; - } - - final contacts = await twonlyDB.contactsDao.getAllNotBlockedContacts(); - - for (final contact in contacts) { - await sendCipherText(contact.userId, encryptedContent); - } + await sendCipherText(contactId, encryptedContent); } diff --git a/lib/src/views/chats/add_new_user.view.dart b/lib/src/views/chats/add_new_user.view.dart index a139303..aef43d6 100644 --- a/lib/src/views/chats/add_new_user.view.dart +++ b/lib/src/views/chats/add_new_user.view.dart @@ -284,7 +284,7 @@ class ContactsListView extends StatelessWidget { ), ), ); - await notifyContactsAboutProfileChange(); + await sendContactMyProfileData(contact.userId); }, ), ]; diff --git a/lib/src/views/settings/profile/modify_avatar.view.dart b/lib/src/views/settings/profile/modify_avatar.view.dart index e496e14..219daa4 100644 --- a/lib/src/views/settings/profile/modify_avatar.view.dart +++ b/lib/src/views/settings/profile/modify_avatar.view.dart @@ -31,7 +31,6 @@ class _ModifyAvatarState extends State { ..avatarCounter = user.avatarCounter + 1; return user; }); - await notifyContactsAboutProfileChange(); } AvatarMakerThemeData getAvatarMakerTheme(BuildContext context) { diff --git a/lib/src/views/settings/profile/profile.view.dart b/lib/src/views/settings/profile/profile.view.dart index 0305740..dbe028c 100644 --- a/lib/src/views/settings/profile/profile.view.dart +++ b/lib/src/views/settings/profile/profile.view.dart @@ -52,7 +52,6 @@ class _ProfileViewState extends State { ..avatarCounter = user.avatarCounter + 1; return user; }); - await notifyContactsAboutProfileChange(); setState(() {}); // gUser has updated } @@ -86,7 +85,6 @@ class _ProfileViewState extends State { ..avatarCounter = user.avatarCounter + 1; return user; }); - await notifyContactsAboutProfileChange(); setState(() {}); // gUser has updated }