Skip to content

Commit ffca449

Browse files
Update src/widgets/peopleSearch.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent ed726ad commit ffca449

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

src/widgets/peopleSearch.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -289,21 +289,25 @@ export const createPeopleSearch = function (dom, kb, me: NamedNode | null, onCli
289289
return nextContacts
290290
}
291291

292-
const contacts = kb.each(current, ns.foaf('knows')) as NamedNode[]
292+
const contacts = kb.each(current, ns.foaf('knows'))
293293
for (const contact of contacts) {
294-
const contactName = nameFor(contact)
295-
if (contact.value !== me.value && contactName && !emitted.has(contact.value)) {
296-
emitted.add(contact.value)
294+
if (contact.termType !== 'NamedNode') {
295+
continue
296+
}
297+
const namedContact = contact as NamedNode
298+
const contactName = nameFor(namedContact)
299+
if (namedContact.value !== me.value && contactName && !emitted.has(namedContact.value)) {
300+
emitted.add(namedContact.value)
297301
await onPerson({
298302
name: contactName,
299-
webId: contact.value,
303+
webId: namedContact.value,
300304
relationshipLabel: depth === 0 ? 'Friend' : 'People'
301305
})
302306
}
303307

304-
if (contact instanceof NamedNode && !visited.has(contact.value)) {
305-
visited.add(contact.value)
306-
nextContacts.push({ person: contact, depth: depth + 1 })
308+
if (!visited.has(namedContact.value)) {
309+
visited.add(namedContact.value)
310+
nextContacts.push({ person: namedContact, depth: depth + 1 })
307311
}
308312
}
309313

0 commit comments

Comments
 (0)