contacts-pane 2.6.5 → 2.6.6-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/contactsPane.js +26 -16
- package/package.json +1 -1
package/contactsPane.js
CHANGED
|
@@ -604,23 +604,33 @@ export default {
|
|
|
604
604
|
let ds = []
|
|
605
605
|
let ins = []
|
|
606
606
|
groups.forEach(group => {
|
|
607
|
+
// check for WebId's in VCARD('hasMember)
|
|
608
|
+
const members = kb.statementsMatching(group, ns.vcard('hasMember'), null, group.doc()).map(st => st.object)
|
|
609
|
+
console.log('Alain ' + members)
|
|
610
|
+
const newModel = members.some(member => !kb.any(member, ns.vcard('fn'), null, group.doc())) ? true : false
|
|
611
|
+
// if newModel, shall we check that sameAs is in expected order ?
|
|
612
|
+
console.log(newModel)
|
|
613
|
+
if (!newModel) {
|
|
614
|
+
// update to new model
|
|
607
615
|
let vcardOrWebids = kb.statementsMatching(null, ns.owl('sameAs'), null, group.doc()).map(st => st.subject)
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
.concat($rdf.st(
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
616
|
+
const strings = new Set(vcardOrWebids.map(contact => contact.uri)) // remove dups
|
|
617
|
+
vcardOrWebids = [...strings].map(uri => kb.sym(uri))
|
|
618
|
+
vcardOrWebids.forEach(item => {
|
|
619
|
+
if (kb.each(item, ns.vcard('fn'), null, group.doc()).length) {
|
|
620
|
+
// delete item, it is an old data model, item is a card not a webid.
|
|
621
|
+
ds = ds.concat(kb
|
|
622
|
+
.statementsMatching(item, ns.owl('sameAs'), null, group.doc())
|
|
623
|
+
.statementsMatching(null, ns.owl('sameAs'), item, group.doc()) // and also reverse
|
|
624
|
+
.concat(kb.statementsMatching(undefined, undefined, item, group.doc())))
|
|
625
|
+
// add card webids to group
|
|
626
|
+
const webids = kb.each(item, ns.owl('sameAs'), null, group.doc())
|
|
627
|
+
webids.forEach(webid => {
|
|
628
|
+
ins = ins.concat($rdf.st(webid, ns.owl('sameAs'), item, group.doc()))
|
|
629
|
+
.concat($rdf.st(group, ns.vcard('hasMember'), webid, group.doc()))
|
|
630
|
+
})
|
|
631
|
+
}
|
|
632
|
+
})
|
|
633
|
+
}
|
|
624
634
|
})
|
|
625
635
|
if (ds.length && confirm('Groups data model need to be updated ?')) {
|
|
626
636
|
await kb.updater.updateMany(ds, ins)
|