Skip to content

Commit

Permalink
fix getTypeIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
soltanireza65 committed Dec 22, 2023
1 parent 621ab9f commit 31ee1e9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/TypeIndexHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,29 +82,28 @@ 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,
typeIndexPredicate,
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))
Expand Down

0 comments on commit 31ee1e9

Please sign in to comment.