Skip to content

Commit 031cd79

Browse files
committed
Merge branch 'feature/widget-peoplesearch' of https://github.com/SolidOS/solid-ui into feature/widget-peoplesearch
2 parents 3187885 + ffca449 commit 031cd79

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

src/widgets/peopleSearch.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* opens their profile in a new tab or window.
1616
*
1717
* 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.
1919
*
2020
*/
2121
import { NamedNode, type LiveStore } from 'rdflib'
@@ -294,21 +294,25 @@ export const createPeopleSearch = function (
294294
return nextContacts
295295
}
296296

297-
const contacts = kb.each(current, ns.foaf('knows')) as NamedNode[]
297+
const contacts = kb.each(current, ns.foaf('knows'))
298298
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)
302306
await onPerson({
303307
name: contactName,
304-
webId: contact.value,
308+
webId: namedContact.value,
305309
relationshipLabel: depth === 0 ? 'Friend' : 'People'
306310
})
307311
}
308312

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 })
312316
}
313317
}
314318

0 commit comments

Comments
 (0)