This commit is contained in:
otsmr 2025-12-29 16:13:57 +01:00
parent ea68dcaf1c
commit ebf53a5ab4
5 changed files with 9 additions and 20 deletions

View file

@ -93,7 +93,7 @@ Future<void> handleContactUpdate(
switch (contactUpdate.type) { switch (contactUpdate.type) {
case EncryptedContent_ContactUpdate_Type.REQUEST: case EncryptedContent_ContactUpdate_Type.REQUEST:
Log.info('Got a contact update request from $fromUserId'); Log.info('Got a contact update request from $fromUserId');
await notifyContactsAboutProfileChange(onlyToContact: fromUserId); await sendContactMyProfileData(fromUserId);
case EncryptedContent_ContactUpdate_Type.UPDATE: case EncryptedContent_ContactUpdate_Type.UPDATE:
Log.info('Got a contact update $fromUserId'); Log.info('Got a contact update $fromUserId');

View file

@ -289,26 +289,18 @@ Future<void> notifyContactAboutOpeningMessage(
await updateLastMessageId(contactId, biggestMessageId); await updateLastMessageId(contactId, biggestMessageId);
} }
Future<void> notifyContactsAboutProfileChange({int? onlyToContact}) async { Future<void> sendContactMyProfileData(int contactId) async {
if (gUser.avatarSvg == null) return; List<int>? avatarSvgCompressed;
if (gUser.avatarSvg != null) {
avatarSvgCompressed = gzip.encode(utf8.encode(gUser.avatarSvg!));
}
final encryptedContent = pb.EncryptedContent( final encryptedContent = pb.EncryptedContent(
contactUpdate: pb.EncryptedContent_ContactUpdate( contactUpdate: pb.EncryptedContent_ContactUpdate(
type: pb.EncryptedContent_ContactUpdate_Type.UPDATE, type: pb.EncryptedContent_ContactUpdate_Type.UPDATE,
avatarSvgCompressed: gzip.encode(utf8.encode(gUser.avatarSvg!)), avatarSvgCompressed: avatarSvgCompressed,
displayName: gUser.displayName, displayName: gUser.displayName,
username: gUser.username, username: gUser.username,
), ),
); );
await sendCipherText(contactId, encryptedContent);
if (onlyToContact != null) {
await sendCipherText(onlyToContact, encryptedContent);
return;
}
final contacts = await twonlyDB.contactsDao.getAllNotBlockedContacts();
for (final contact in contacts) {
await sendCipherText(contact.userId, encryptedContent);
}
} }

View file

@ -284,7 +284,7 @@ class ContactsListView extends StatelessWidget {
), ),
), ),
); );
await notifyContactsAboutProfileChange(); await sendContactMyProfileData(contact.userId);
}, },
), ),
]; ];

View file

@ -31,7 +31,6 @@ class _ModifyAvatarState extends State<ModifyAvatar> {
..avatarCounter = user.avatarCounter + 1; ..avatarCounter = user.avatarCounter + 1;
return user; return user;
}); });
await notifyContactsAboutProfileChange();
} }
AvatarMakerThemeData getAvatarMakerTheme(BuildContext context) { AvatarMakerThemeData getAvatarMakerTheme(BuildContext context) {

View file

@ -52,7 +52,6 @@ class _ProfileViewState extends State<ProfileView> {
..avatarCounter = user.avatarCounter + 1; ..avatarCounter = user.avatarCounter + 1;
return user; return user;
}); });
await notifyContactsAboutProfileChange();
setState(() {}); // gUser has updated setState(() {}); // gUser has updated
} }
@ -86,7 +85,6 @@ class _ProfileViewState extends State<ProfileView> {
..avatarCounter = user.avatarCounter + 1; ..avatarCounter = user.avatarCounter + 1;
return user; return user;
}); });
await notifyContactsAboutProfileChange();
setState(() {}); // gUser has updated setState(() {}); // gUser has updated
} }