Skip to content

Commit

Permalink
literal cache test
Browse files Browse the repository at this point in the history
  • Loading branch information
thisismattmiller committed Jun 28, 2024
1 parent 6c94c25 commit d60a3cc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 19 additions & 2 deletions src/stores/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ const LABEL_PREDICATES = [
'http://id.loc.gov/ontologies/bibframe/code',
]

let cachePt = {}
let cacheGuid = {}

export const useProfileStore = defineStore('profile', {
state: () => ({

Expand Down Expand Up @@ -1264,14 +1267,28 @@ export const useProfileStore = defineStore('profile', {
setValueLiteral: async function(componentGuid, fieldGuid, propertyPath, value, lang, repeatedLiteral){
let lastProperty = propertyPath.at(-1).propertyURI
// locate the correct pt to work on in the activeProfile
let pt = utilsProfile.returnPt(this.activeProfile,componentGuid)
let pt
if (cachePt[componentGuid]){
pt = cachePt[componentGuid]
}else{
pt = utilsProfile.returnPt(this.activeProfile,componentGuid)
cachePt[componentGuid] = pt
}
// let pt = utilsProfile.returnPt(this.activeProfile,componentGuid)
console.log(componentGuid, fieldGuid, propertyPath, value, lang, repeatedLiteral)
if (pt !== false){

pt.hasData = true

// find the correct blank node to edit if possible, if we don't find it then we need to create it
let blankNode = utilsProfile.returnGuidLocation(pt.userValue,fieldGuid)
let blankNode
if (cacheGuid[fieldGuid]){
blankNode = cacheGuid[fieldGuid]
}else{
blankNode = utilsProfile.returnGuidLocation(pt.userValue,fieldGuid)
cacheGuid[fieldGuid] = blankNode
}
// let blankNode = utilsProfile.returnGuidLocation(pt.userValue,fieldGuid)
console.log("blankNode -->",blankNode)
if (blankNode === false){
// create the path to the blank node
Expand Down
2 changes: 1 addition & 1 deletion src/views/Edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
// }, { detached: true })
if (state.profilesLoaded && Object.keys(state.activeProfile).length == 0){
if (this.profilesLoaded && this.activeProfile && Object.keys(this.activeProfile).length == 0){
// the profilesLoaded flipped and there is no active profile, so load the data
this.profileStore.loadRecordFromBackend(this.$route.params.recordId)
}else{
Expand Down

0 comments on commit d60a3cc

Please sign in to comment.