|
|
|
@ -307,14 +307,14 @@ export default class EntityGrid extends Vue { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Get the 3 most recently added contacts (when showing contacts and not searching) |
|
|
|
* Get the most recently added contacts (when showing contacts and not searching) |
|
|
|
*/ |
|
|
|
get recentContacts(): Contact[] { |
|
|
|
if (this.entityType !== "people" || this.searchTerm.trim()) { |
|
|
|
return []; |
|
|
|
} |
|
|
|
// Entities are already sorted by date added (newest first) |
|
|
|
return (this.entities as Contact[]).slice(0, 3); |
|
|
|
return (this.entities as Contact[]).slice(0, RECENT_CONTACTS_COUNT); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -325,16 +325,16 @@ export default class EntityGrid extends Vue { |
|
|
|
if (this.entityType !== "people" || this.searchTerm.trim()) { |
|
|
|
return []; |
|
|
|
} |
|
|
|
// Skip the first 3 (recent contacts) and sort the rest alphabetically |
|
|
|
// Skip the first few (recent contacts) and sort the rest alphabetically |
|
|
|
// Create a copy to avoid mutating the original array |
|
|
|
const remaining = (this.entities as Contact[]).slice(RECENT_CONTACTS_COUNT); |
|
|
|
const remaining = this.entities as Contact[]; |
|
|
|
const sorted = [...remaining].sort((a: Contact, b: Contact) => { |
|
|
|
// Sort alphabetically by name, falling back to DID if name is missing |
|
|
|
const nameA = (a.name || a.did).toLowerCase(); |
|
|
|
const nameB = (b.name || b.did).toLowerCase(); |
|
|
|
return nameA.localeCompare(nameB); |
|
|
|
}); |
|
|
|
// Apply infinite scroll: show based on displayedCount (minus the 3 recent) |
|
|
|
// Apply infinite scroll: show based on displayedCount (minus the recent contacts) |
|
|
|
const toShow = Math.max(0, this.displayedCount - RECENT_CONTACTS_COUNT); |
|
|
|
return sorted.slice(0, toShow); |
|
|
|
} |
|
|
|
@ -531,9 +531,8 @@ export default class EntityGrid extends Vue { |
|
|
|
} |
|
|
|
|
|
|
|
// People: check if more alphabetical contacts available |
|
|
|
// Total available = 3 recent + all alphabetical |
|
|
|
const remaining = (this.entities as Contact[]).slice(RECENT_CONTACTS_COUNT); |
|
|
|
const totalAvailable = RECENT_CONTACTS_COUNT + remaining.length; |
|
|
|
// Total available = recent + all alphabetical |
|
|
|
const totalAvailable = RECENT_CONTACTS_COUNT + this.entities.length; |
|
|
|
return this.displayedCount < totalAvailable; |
|
|
|
} |
|
|
|
|
|
|
|
|