mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 07:48:40 +00:00
fix #362
This commit is contained in:
parent
ea68dcaf1c
commit
ebf53a5ab4
5 changed files with 9 additions and 20 deletions
|
|
@ -93,7 +93,7 @@ Future<void> 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');
|
||||
|
|
|
|||
|
|
@ -289,26 +289,18 @@ Future<void> notifyContactAboutOpeningMessage(
|
|||
await updateLastMessageId(contactId, biggestMessageId);
|
||||
}
|
||||
|
||||
Future<void> notifyContactsAboutProfileChange({int? onlyToContact}) async {
|
||||
if (gUser.avatarSvg == null) return;
|
||||
|
||||
Future<void> sendContactMyProfileData(int contactId) async {
|
||||
List<int>? 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ class ContactsListView extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
);
|
||||
await notifyContactsAboutProfileChange();
|
||||
await sendContactMyProfileData(contact.userId);
|
||||
},
|
||||
),
|
||||
];
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ class _ModifyAvatarState extends State<ModifyAvatar> {
|
|||
..avatarCounter = user.avatarCounter + 1;
|
||||
return user;
|
||||
});
|
||||
await notifyContactsAboutProfileChange();
|
||||
}
|
||||
|
||||
AvatarMakerThemeData getAvatarMakerTheme(BuildContext context) {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ class _ProfileViewState extends State<ProfileView> {
|
|||
..avatarCounter = user.avatarCounter + 1;
|
||||
return user;
|
||||
});
|
||||
await notifyContactsAboutProfileChange();
|
||||
setState(() {}); // gUser has updated
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +85,6 @@ class _ProfileViewState extends State<ProfileView> {
|
|||
..avatarCounter = user.avatarCounter + 1;
|
||||
return user;
|
||||
});
|
||||
await notifyContactsAboutProfileChange();
|
||||
setState(() {}); // gUser has updated
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue