1
0
Fork 0
mirror of synced 2024-09-20 19:33:10 +12:00

PR feedback. Remove unnecessary caching

This commit is contained in:
Dean 2024-07-18 14:17:51 +01:00
parent 2f8a6b9b6b
commit 7c03a39b9f

View file

@ -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