Commit 08209abf authored by Anton's avatar Anton

Add getLocal action to metadata store module, use in videos/list

parent faec4452
......@@ -25,7 +25,7 @@
for (let i in rows) {
const transformed = {}
const row = rows[i]
const meta = await _this.$store.dispatch('metadata/get', row)
const meta = await _this.$store.dispatch('metadata/getLocal', row)
transformed.title = meta && meta.title ? meta.title : _this.$t('labels.title_unknown')
if (row.target.selector) {
const parsed = row.target.selector.parse()
......
......@@ -49,6 +49,29 @@ const metadata = {
}
console.debug('metadata', metadata)
return metadata
},
async getLocal (context, payload) {
Assert.ok(typeof payload === 'string' || typeof payload.body.source.id === 'string',
'Metadata request payload must be UUID string or annotation object')
let metadataURL
if (typeof payload === 'string') metadataURL = `${process.env.TRANSCODER_HOST}/metadata/${payload}`
else metadataURL = `${process.env.TRANSCODER_HOST}/metadata/url?url=${encodeURIComponent(payload.body.source.id)}`
let metadata
metadata = context.state.cache[metadataURL] || {}
const titleQuery = {
'target.id': typeof payload === 'string' ? `${BASE_URI}/annotations/${payload}` : payload.id,
'body.purpose': 'describing',
'body.type': 'TextualBody'
}
const titleResult = await context.dispatch('annotations/find', titleQuery, {root: true})
if (titleResult && titleResult.items && titleResult.items.length) {
metadata.titleAnnotation = titleResult.items[0]
if (metadata.title) metadata.originalTitle = metadata.title
metadata.title = titleResult.items[0].body.value
}
console.debug('metadata', 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