Browse Source

fix: replace computeAsync with custom watch to avoid unnecessary formula helper functions

pull/9662/head
Pranav C 1 month ago
parent
commit
4471bab718
  1. 19
      packages/nc-gui/components/smartsheet/column/FormulaOptions.vue

19
packages/nc-gui/components/smartsheet/column/FormulaOptions.vue

@ -85,22 +85,29 @@ if ((column.value?.colOptions as any)?.formula_raw) {
const source = computed(() => activeBase.value?.sources?.find((s) => s.id === meta.value?.source_id)) const source = computed(() => activeBase.value?.sources?.find((s) => s.id === meta.value?.source_id))
const parsedTree = computedAsync(async () => { const parsedTree = ref({
dataType: FormulaDataTypes.UNKNOWN,
})
watch(
() => vModel.value.formula || vModel.value.formula_raw,
async () => {
try { try {
const parsed = await validateFormulaAndExtractTreeWithType({ const parsed = await validateFormulaAndExtractTreeWithType({
formula: vModel.value.formula || vModel.value.formula_raw, formula: vModel.value.formula || vModel.value.formula_raw,
columns: meta.value?.columns || [], columns: (meta.value?.columns || []).slice(),
column: column.value ?? undefined, column: column.value ? { ...column.value } : undefined,
clientOrSqlUi: source.value?.type as any, clientOrSqlUi: source.value?.type as any,
getMeta: async (modelId) => await getMeta(modelId), getMeta: async (modelId) => await getMeta(modelId),
}) })
return parsed parsedTree.value = parsed
} catch (e) { } catch (e) {
return { parsedTree.value = {
dataType: FormulaDataTypes.UNKNOWN, dataType: FormulaDataTypes.UNKNOWN,
} }
} }
}) },
)
// set additional validations // set additional validations
setAdditionalValidations({ setAdditionalValidations({

Loading…
Cancel
Save