Don't bother fetching data if no calculations defined

This commit is contained in:
Andrew Kingston 2024-10-10 14:52:13 +01:00
parent bf1bf1956a
commit 1cbae36683
No known key found for this signature in database
2 changed files with 15 additions and 1 deletions

View File

@ -164,7 +164,6 @@ export const initialise = context => {
}
// Override a few properties for primary display
if (field === primaryDisplay) {
column.visible = true
column.order = 0
column.primaryDisplay = true
}

View File

@ -1,3 +1,4 @@
import { ViewV2Type } from "@budibase/types"
import DataFetch from "./DataFetch.js"
import { get } from "svelte/store"
@ -39,6 +40,19 @@ export default class ViewV2Fetch extends DataFetch {
this.options
const { cursor, query, definition } = get(this.store)
// If this is a calculation view and we have no calculations, return nothing
if (
definition.type === ViewV2Type.CALCULATION &&
!Object.values(definition.schema || {}).some(x => x.calculationType)
) {
return {
rows: [],
hasNextPage: false,
cursor: null,
error: null,
}
}
// If sort/filter params are not defined, update options to store the
// params built in to this view. This ensures that we can accurately
// compare old and new params and skip a redundant API call.
@ -67,6 +81,7 @@ export default class ViewV2Fetch extends DataFetch {
return {
rows: [],
hasNextPage: false,
cursor: null,
error,
}
}