Browse Source

fix contact sorting to show those without names

kb/add-usage-guide
Trent Larson 7 months ago
parent
commit
405bc22dae
  1. 10
      src/views/ContactGiftingView.vue
  2. 16
      src/views/ContactsView.vue
  3. 2
      src/views/NewEditAccountView.vue

10
src/views/ContactGiftingView.vue

@ -99,12 +99,10 @@ export default class ContactGiftingView extends Vue {
allContacts: Array<Contact> = []; allContacts: Array<Contact> = [];
apiServer = ""; apiServer = "";
accounts: typeof AccountsSchema; accounts: typeof AccountsSchema;
numAccounts = 0;
projectId = localStorage.getItem("projectId") || ""; projectId = localStorage.getItem("projectId") || "";
async beforeCreate() { async beforeCreate() {
accountsDB.open(); accountsDB.open();
this.numAccounts = await accountsDB.accounts.count();
} }
async created() { async created() {
@ -113,7 +111,13 @@ export default class ContactGiftingView extends Vue {
const settings = (await db.settings.get(MASTER_SETTINGS_KEY)) as Settings; const settings = (await db.settings.get(MASTER_SETTINGS_KEY)) as Settings;
this.apiServer = settings?.apiServer || ""; this.apiServer = settings?.apiServer || "";
this.activeDid = settings?.activeDid || ""; 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"); localStorage.removeItem("projectId");

16
src/views/ContactsView.vue

@ -364,7 +364,13 @@ export default class ContactsView extends Vue {
if (this.showGiveNumbers) { if (this.showGiveNumbers) {
this.loadGives(); 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) { if (this.contactEndorserUrl) {
await this.addContactFromScan(this.contactEndorserUrl); await this.addContactFromScan(this.contactEndorserUrl);
@ -560,7 +566,13 @@ export default class ContactsView extends Vue {
-1, -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; return;
} }

2
src/views/NewEditAccountView.vue

@ -33,7 +33,7 @@
<!-- SHOW ME instead while processing saving changes --> <!-- SHOW ME instead while processing saving changes -->
<button <button
type="button" type="button"
class="block w-full text-center text-md uppercase bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-1.5 py-2 rounded-md" class="block w-full text-center text-md uppercase bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-2 py-3 rounded-md mb-2"
@click="onClickCancel()" @click="onClickCancel()"
> >
Cancel Cancel

Loading…
Cancel
Save