From 9b350d437321efe48f42e0d201efc44efbb74202 Mon Sep 17 00:00:00 2001 From: Moonbase Date: Wed, 10 Dec 2025 13:49:10 -0800 Subject: [PATCH] Reimplement Contact List Images --- qtcnet-client/Forms/MainForm.cs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/qtcnet-client/Forms/MainForm.cs b/qtcnet-client/Forms/MainForm.cs index 2fae754..9be2c8e 100644 --- a/qtcnet-client/Forms/MainForm.cs +++ b/qtcnet-client/Forms/MainForm.cs @@ -893,15 +893,20 @@ namespace qtcnet_client { case Contact.ContactStatus.AwaitingApprovalFromOther: ctrl.Username = $"{user.Data.Username} [Request Sent]"; - //await AddProfilePicToList(user.Data.Id); - //ctrl.Avatar = ilProfilePics.Images[user.Data.Id] ?? ilProfilePics.Images[0]; break; case Contact.ContactStatus.Accepted: ctrl.Username = user.Data.Username; - //await AddProfilePicToList(user.Data.Id); - //ctrl.Avatar = ilProfilePics.Images[user.Data.Id] ?? ilProfilePics.Images[0]; break; } + + // get profile image + var _pfpRes = await _apiService.GetUserProfilePic(contact.UserId); + if(_pfpRes.Success && _pfpRes.Data != null) + { + using var ms = new MemoryStream(_pfpRes.Data); + Image img = Image.FromStream(ms); + ctrl.ProfilePic = img; + } } else if (contact.UserId == _apiService.CurrentUser.Id) { @@ -909,16 +914,21 @@ namespace qtcnet_client { case Contact.ContactStatus.AwaitingApprovalFromSelf: ctrl.Username = $"{user.Data.Username} [Contact Request]"; - //await AddProfilePicToList(user.Data.Id); - //ctrl.Avatar = ilProfilePics.Images[user.Data.Id] ?? ilProfilePics.Images[0]; //AudioService.PlaySoundEffect("sndContactRequest"); break; case Contact.ContactStatus.Accepted: ctrl.Username = user.Data.Username; - //await AddProfilePicToList(user.Data.Id); - //ctrl.Avatar = ilProfilePics.Images[user.Data.Id] ?? ilProfilePics.Images[0]; break; } + + // get profile image + var _pfpRes = await _apiService.GetUserProfilePic(contact.OwnerId); + if (_pfpRes.Success && _pfpRes.Data != null) + { + using var ms = new MemoryStream(_pfpRes.Data); + Image img = Image.FromStream(ms); + ctrl.ProfilePic = img; + } } // return the control