From 405bc22daec74ff84f71fe50046bb640df6449df Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Wed, 17 Apr 2024 19:29:17 -0600 Subject: [PATCH] fix contact sorting to show those without names --- src/views/ContactGiftingView.vue | 10 +++++++--- src/views/ContactsView.vue | 16 ++++++++++++++-- src/views/NewEditAccountView.vue | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/views/ContactGiftingView.vue b/src/views/ContactGiftingView.vue index ec2f288..d522729 100644 --- a/src/views/ContactGiftingView.vue +++ b/src/views/ContactGiftingView.vue @@ -99,12 +99,10 @@ export default class ContactGiftingView extends Vue { allContacts: Array = []; apiServer = ""; accounts: typeof AccountsSchema; - numAccounts = 0; projectId = localStorage.getItem("projectId") || ""; async beforeCreate() { accountsDB.open(); - this.numAccounts = await accountsDB.accounts.count(); } async created() { @@ -113,7 +111,13 @@ export default class ContactGiftingView extends Vue { const settings = (await db.settings.get(MASTER_SETTINGS_KEY)) as Settings; this.apiServer = settings?.apiServer || ""; this.activeDid = settings?.activeDid || ""; - this.allContacts = 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.allContacts = baseContacts.sort((a, b) => + (a.name || "").localeCompare(b.name || ""), + ); localStorage.removeItem("projectId"); diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue index 1f4c900..e5c699b 100644 --- a/src/views/ContactsView.vue +++ b/src/views/ContactsView.vue @@ -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; } diff --git a/src/views/NewEditAccountView.vue b/src/views/NewEditAccountView.vue index cae8c7d..b98fef7 100644 --- a/src/views/NewEditAccountView.vue +++ b/src/views/NewEditAccountView.vue @@ -33,7 +33,7 @@