Fix A Bug Where Some Contacts Won't Be Populated Into The Contacts List
This commit is contained in:
parent
fb039c6b87
commit
a970fd1b5c
@ -816,15 +816,10 @@ namespace qtc_net_client_2
|
|||||||
if (!contactsRes.Success || contactsRes.Data == null)
|
if (!contactsRes.Success || contactsRes.Data == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var uniqueContacts = contactsRes.Data
|
|
||||||
.GroupBy(c => c.UserId)
|
|
||||||
.Select(g => g.First())
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
if (InvokeRequired)
|
if (InvokeRequired)
|
||||||
Invoke(() => ApplyContacts(uniqueContacts));
|
Invoke(() => ApplyContacts(contactsRes.Data));
|
||||||
else
|
else
|
||||||
ApplyContacts(uniqueContacts);
|
ApplyContacts(contactsRes.Data);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -840,15 +835,14 @@ namespace qtc_net_client_2
|
|||||||
e.UserStatus == Contact.ContactStatus.AwaitingApprovalFromSelf);
|
e.UserStatus == Contact.ContactStatus.AwaitingApprovalFromSelf);
|
||||||
|
|
||||||
Contacts.Clear();
|
Contacts.Clear();
|
||||||
Contacts.AddRange(newContacts.DistinctBy(c => c.UserId));
|
Contacts.AddRange(newContacts.DistinctBy(c => c.Id));
|
||||||
|
|
||||||
// Snapshot to avoid concurrent modification
|
|
||||||
var contactsSnapshot = Contacts.ToList();
|
|
||||||
|
|
||||||
flpContacts.SuspendLayout();
|
flpContacts.SuspendLayout();
|
||||||
flpContacts.Controls.Clear();
|
flpContacts.Controls.Clear();
|
||||||
|
|
||||||
foreach (var contact in contactsSnapshot)
|
var contactsSnap = Contacts.ToList();
|
||||||
|
|
||||||
|
foreach (var contact in contactsSnap)
|
||||||
{
|
{
|
||||||
var ctrl = await BuildContactControl(contact);
|
var ctrl = await BuildContactControl(contact);
|
||||||
if (ctrl != null)
|
if (ctrl != null)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user