From 31ee1e9fe48b9d372e9159f54a98c712eb04cfae Mon Sep 17 00:00:00 2001 From: Reza Soltani Date: Fri, 22 Dec 2023 19:45:15 +0330 Subject: [PATCH] fix getTypeIndex --- src/TypeIndexHelper.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/TypeIndexHelper.ts b/src/TypeIndexHelper.ts index 1ae0121..7af7bff 100644 --- a/src/TypeIndexHelper.ts +++ b/src/TypeIndexHelper.ts @@ -82,12 +82,14 @@ export class TypeIndexHelper { const typeIndexPredicate = TypeIndexHelper.getTypeIndexPredicate(isPrivate); const typeIndexUrl = TypeIndexHelper.getDefaultTypeIndexURL(webId, isPrivate); + const profileDS = await getSolidDataset(webId, { fetch }); + if (profileMe) { let typeIndex = getNamedNode(profileMe, typeIndexPredicate); if (typeIndex) return typeIndex; - const typeIndexDS = await this.createTypeIndex(fetch, typeIndexUrl); + await this.createTypeIndex(fetch, typeIndexUrl); const updatedProfileMe = addNamedNode( profileMe, @@ -95,16 +97,13 @@ export class TypeIndexHelper { namedNode(typeIndexUrl) ); - const updatedTypeIndexDS = setThing(typeIndexDS!, updatedProfileMe); + const updatedProfileDS = setThing(profileDS, updatedProfileMe); - await saveSolidDatasetAt(typeIndexUrl, updatedTypeIndexDS, { - fetch, - }); + await saveSolidDatasetAt(webId, updatedProfileDS, { fetch }); return namedNode(typeIndexUrl); } else { await this.createTypeIndex(fetch, typeIndexUrl); - const profileDS = await getSolidDataset(webId, { fetch }); const profileMeThing = buildThing(createThing({ name: "me" })) .addNamedNode(typeIndexPredicate, namedNode(typeIndexUrl))