|
15 | 15 | * opens their profile in a new tab or window. |
16 | 16 | * |
17 | 17 | * Assumptions |
18 | | - * - Assumes that the user has a type index entry for vcard:AddressBook. @@ bad assuption |
| 18 | + * - Assumes that the user has a type index entry for vcard:AddressBook. If this assumption is not met, no address book contacts will be discovered. |
19 | 19 | * |
20 | 20 | */ |
21 | 21 | import { NamedNode, type LiveStore } from 'rdflib' |
@@ -294,21 +294,25 @@ export const createPeopleSearch = function ( |
294 | 294 | return nextContacts |
295 | 295 | } |
296 | 296 |
|
297 | | - const contacts = kb.each(current, ns.foaf('knows')) as NamedNode[] |
| 297 | + const contacts = kb.each(current, ns.foaf('knows')) |
298 | 298 | for (const contact of contacts) { |
299 | | - const contactName = nameFor(contact) |
300 | | - if (contact.value !== me.value && contactName && !emitted.has(contact.value)) { |
301 | | - emitted.add(contact.value) |
| 299 | + if (contact.termType !== 'NamedNode') { |
| 300 | + continue |
| 301 | + } |
| 302 | + const namedContact = contact as NamedNode |
| 303 | + const contactName = nameFor(namedContact) |
| 304 | + if (namedContact.value !== me.value && contactName && !emitted.has(namedContact.value)) { |
| 305 | + emitted.add(namedContact.value) |
302 | 306 | await onPerson({ |
303 | 307 | name: contactName, |
304 | | - webId: contact.value, |
| 308 | + webId: namedContact.value, |
305 | 309 | relationshipLabel: depth === 0 ? 'Friend' : 'People' |
306 | 310 | }) |
307 | 311 | } |
308 | 312 |
|
309 | | - if (contact instanceof NamedNode && !visited.has(contact.value)) { |
310 | | - visited.add(contact.value) |
311 | | - nextContacts.push({ person: contact, depth: depth + 1 }) |
| 313 | + if (!visited.has(namedContact.value)) { |
| 314 | + visited.add(namedContact.value) |
| 315 | + nextContacts.push({ person: namedContact, depth: depth + 1 }) |
312 | 316 | } |
313 | 317 | } |
314 | 318 |
|
|
0 commit comments