Adding check to not re-fetch default value.

This commit is contained in:
mike12345567 2023-10-13 11:44:15 +01:00
parent d44ad549ef
commit ccfc98120d
1 changed files with 3 additions and 1 deletions

View File

@ -25,6 +25,7 @@
let tableDefinition let tableDefinition
let searchTerm let searchTerm
let open let open
let hasFetchedDefaultValue
$: type = $: type =
datasourceType === "table" ? FieldTypes.LINK : FieldTypes.BB_REFERENCE datasourceType === "table" ? FieldTypes.LINK : FieldTypes.BB_REFERENCE
@ -116,7 +117,7 @@
if (allRowsFetched || !primaryDisplay) { if (allRowsFetched || !primaryDisplay) {
return return
} }
if (defaultVal) { if (defaultVal && !hasFetchedDefaultValue) {
await fetch.update({ await fetch.update({
query: { equal: { _id: defaultVal } }, query: { equal: { _id: defaultVal } },
}) })
@ -124,6 +125,7 @@
if (defaultRow) { if (defaultRow) {
optionsObj[defaultRow._id] = defaultRow optionsObj[defaultRow._id] = defaultRow
} }
hasFetchedDefaultValue = true
} }
await fetch.update({ await fetch.update({
query: { string: { [primaryDisplay]: searchTerm } }, query: { string: { [primaryDisplay]: searchTerm } },