fix contact sorting to show those without names

This commit is contained in:
2024-04-17 19:29:17 -06:00
parent 60b2bf35fb
commit 48a46cf6f1
3 changed files with 22 additions and 6 deletions

View File

@@ -364,7 +364,13 @@ export default class ContactsView extends Vue {
if (this.showGiveNumbers) {
this.loadGives();
}
this.contacts = await db.contacts.orderBy("name").toArray();
// .orderBy("name") wouldn't retrieve any entries with a blank name
// .toCollection.sortBy("name") didn't sort in an order I understood
const baseContacts = await db.contacts.toArray();
this.contacts = baseContacts.sort((a, b) =>
(a.name || "").localeCompare(b.name || ""),
);
if (this.contactEndorserUrl) {
await this.addContactFromScan(this.contactEndorserUrl);
@@ -560,7 +566,13 @@ export default class ContactsView extends Vue {
-1,
);
}
this.contacts = await db.contacts.orderBy("name").toArray();
// .orderBy("name") wouldn't retrieve any entries with a blank name
// .toCollection.sortBy("name") didn't sort in an order I understood
const baseContacts = await db.contacts.toArray();
this.contacts = baseContacts.sort((a, b) =>
(a.name || "").localeCompare(b.name || ""),
);
return;
}