PR feedback. Remove unnecessary caching
This commit is contained in:
parent
2f8a6b9b6b
commit
7c03a39b9f
|
@ -29,7 +29,6 @@
|
||||||
let searching = false
|
let searching = false
|
||||||
let container
|
let container
|
||||||
let anchor
|
let anchor
|
||||||
let cacheStr
|
|
||||||
|
|
||||||
$: fieldValue = parseValue(value)
|
$: fieldValue = parseValue(value)
|
||||||
$: oneRowOnly = schema?.relationshipType === "one-to-many"
|
$: oneRowOnly = schema?.relationshipType === "one-to-many"
|
||||||
|
@ -43,19 +42,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const parseValue = value => {
|
const parseValue = value => {
|
||||||
// Is it unset or a valid array? 1+
|
if (Array.isArray(value) && value.every(x => x?._id)) {
|
||||||
const isValid = val =>
|
return value
|
||||||
!val ||
|
|
||||||
(Array.isArray(val) &&
|
|
||||||
(val.length === 0 ||
|
|
||||||
val.some(relEntry => Object.hasOwn(relEntry, "_id"))))
|
|
||||||
|
|
||||||
const stf = JSON.stringify(value)
|
|
||||||
if (!cacheStr || cacheStr !== stf) {
|
|
||||||
cacheStr = stf
|
|
||||||
return isValid(value) ? [...(value || [])] : []
|
|
||||||
}
|
}
|
||||||
return [...(value || [])]
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
// Builds a lookup map to quickly check which rows are selected
|
// Builds a lookup map to quickly check which rows are selected
|
||||||
|
|
Loading…
Reference in New Issue