From a970fd1b5cfbea210c5bcdee18ac444a8c75d370 Mon Sep 17 00:00:00 2001 From: Moonbase Date: Thu, 27 Nov 2025 12:39:21 -0800 Subject: [PATCH] Fix A Bug Where Some Contacts Won't Be Populated Into The Contacts List --- qtc-net-client-2/Forms/Main.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/qtc-net-client-2/Forms/Main.cs b/qtc-net-client-2/Forms/Main.cs index 1c0e4c0..7668d64 100644 --- a/qtc-net-client-2/Forms/Main.cs +++ b/qtc-net-client-2/Forms/Main.cs @@ -816,15 +816,10 @@ namespace qtc_net_client_2 if (!contactsRes.Success || contactsRes.Data == null) return; - var uniqueContacts = contactsRes.Data - .GroupBy(c => c.UserId) - .Select(g => g.First()) - .ToList(); - if (InvokeRequired) - Invoke(() => ApplyContacts(uniqueContacts)); + Invoke(() => ApplyContacts(contactsRes.Data)); else - ApplyContacts(uniqueContacts); + ApplyContacts(contactsRes.Data); } finally { @@ -840,15 +835,14 @@ namespace qtc_net_client_2 e.UserStatus == Contact.ContactStatus.AwaitingApprovalFromSelf); Contacts.Clear(); - Contacts.AddRange(newContacts.DistinctBy(c => c.UserId)); - - // Snapshot to avoid concurrent modification - var contactsSnapshot = Contacts.ToList(); + Contacts.AddRange(newContacts.DistinctBy(c => c.Id)); flpContacts.SuspendLayout(); flpContacts.Controls.Clear(); - foreach (var contact in contactsSnapshot) + var contactsSnap = Contacts.ToList(); + + foreach (var contact in contactsSnap) { var ctrl = await BuildContactControl(contact); if (ctrl != null)