Fix library moderation
This commit is contained in:
parent
78cdb592c5
commit
fe835c5d44
|
@ -291,25 +291,27 @@ export default {
|
||||||
const previousState = this.previousState
|
const previousState = this.previousState
|
||||||
const fields = Object.keys(payload)
|
const fields = Object.keys(payload)
|
||||||
const self = this
|
const self = this
|
||||||
return fields.map((f) => {
|
|
||||||
const fieldConfig = configs[this.obj.target.type].fields.find(({ id }) => id === f)
|
return fields.map((field) => {
|
||||||
const dummyRepr = (v) => { return v }
|
const fieldConfig = this.configs[this.obj.target.type].fields.find(({ id }) => id === field)
|
||||||
const getValueRepr = fieldConfig.getValueRepr || dummyRepr
|
const getValueRepr = fieldConfig.getValueRepr || (v => v)
|
||||||
const d = {
|
const result = {
|
||||||
id: f,
|
id: field,
|
||||||
config: fieldConfig
|
config: fieldConfig
|
||||||
}
|
}
|
||||||
if (previousState && previousState[f]) {
|
if (previousState?.[field]) {
|
||||||
d.old = previousState[f]
|
result.old = previousState[field]
|
||||||
d.oldRepr = castValue(getValueRepr(d.old.value))
|
// TODO (wvffle): Originally it was using just result.old.value though for some reason it returns me the object as result.old now
|
||||||
|
result.oldRepr = castValue(getValueRepr(result.old.value ?? result.old))
|
||||||
}
|
}
|
||||||
d.new = payload[f]
|
result.new = payload[field]
|
||||||
d.newRepr = castValue(getValueRepr(d.new))
|
result.newRepr = castValue(getValueRepr(result.new))
|
||||||
if (d.old) {
|
if (result.old) {
|
||||||
// we compute the diffs between the old and new values
|
// we compute the diffs between the old and new values
|
||||||
d.diff = diffWordsWithSpace(d.oldRepr, d.newRepr)
|
result.diff = diffWordsWithSpace(result.oldRepr, result.newRepr)
|
||||||
}
|
}
|
||||||
return d
|
|
||||||
|
return result
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue