Commit 78cbeaca authored by Anton's avatar Anton

Refactor metadata store module

parent 461ad869
......@@ -45,9 +45,9 @@ const metadata = {
}
}
if (payload.id) {
metadata = await this.fetchTitle(metadata, payload)
metadata = await context.dispatch('fetchTitle', [metadata, payload])
}
console.debug('metadata', metadata)
console.debug('metadata/get', metadata)
return metadata
},
async getLocal (context, payload) {
......@@ -57,11 +57,12 @@ const metadata = {
if (typeof payload === 'string') {
payload = await context.dispatch('annotations/get', payload, { root: true })
}
let metadata
metadata = context.state.cache[payload.body.source.id] || {}
return this.fetchTitle(context, metadata, payload)
let metadata = context.state.cache[payload.body.source.id] || {}
metadata = await context.dispatch('fetchTitle', [metadata, payload])
console.debug('metadata/getLocal', metadata)
return metadata
},
async fetchTitle (context, metadata, payload) {
async fetchTitle (context, [metadata, payload]) {
const titleQuery = {
'target.id': typeof payload === 'string' ? `${BASE_URI}/annotations/${payload}` : payload.id,
'body.purpose': 'describing',
......@@ -73,7 +74,7 @@ const metadata = {
if (metadata.title) metadata.originalTitle = metadata.title
metadata.title = titleResult.items[0].body.value
}
console.debug('metadata', metadata)
console.debug('metadata/fetchTitle', metadata)
return metadata
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment