Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete contact error #40

Open
bourgeoa opened this issue Apr 19, 2021 · 1 comment
Open

Delete contact error #40

bourgeoa opened this issue Apr 19, 2021 · 1 comment

Comments

@bourgeoa
Copy link
Contributor

bourgeoa commented Apr 19, 2021

Error deleting thing <https://alain.localhost:8443/Contacts/Person/88273c31-f12c-4030-b32c-0bf2b7cbfb0e/index.ttl#this>: TypeError: st is undefined

This is called by https://github.com/solid/contacts-pane/blob/1813eac3b885c3d86fa4ed2882fb73d4ec0fabcf/contactsPane.js#L353

Succeed when replacing :
await kb.updater.updateMany(ds)
by :
for (let i in ds) await kb.updater.update(ds[i])

@bourgeoa
Copy link
Contributor Author

bourgeoa commented Apr 23, 2021

kb.updater.updateMany is a clone of https://github.com/solid/contacts-pane/blob/1813eac3b885c3d86fa4ed2882fb73d4ec0fabcf/contactLogic.js#L13

export async function updateMany (deletions, insertions) {
  const docs = deletions.concat(insertions).map(st => st.why)
  const uniqueDocs = Array.from(new Set(docs))
  const updates = uniqueDocs.map(doc =>
    kb.updater.update(deletions.filter(st => st.why.sameTerm(doc)),
      insertions.filter(st => st.why.sameTerm(doc))))
  return Promise.all(updates)
}

const uniqueDocs = Array.from(new Set(docs)) is incorrect because all objects are different, we must compare the content.
We can use rdflib.js sameTerm or equals that make a node key value comparison in something like :

const uniqueDocs = []
docs.map(doc => {
    if (!uniqueDocs.find(item => item.sameTerm(doc))) uniqueDocs.push(doc)
 })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant