Clean classes

This commit is contained in:
Adria Navarro 2025-01-08 12:55:26 +01:00
parent 7d7c27fa92
commit f053438a64
2 changed files with 8 additions and 15 deletions

View File

@ -223,13 +223,13 @@ export default abstract class DataFetch<
supportsPagination: paginate && !!features?.supportsPagination,
}
// Fetch and enrich schema
let schema = this.getSchema(datasource, definition) ?? null
schema = this.enrichSchema(schema)
if (!schema) {
if (!definition?.schema) {
return
}
// Fetch and enrich schema
const schema = this.enrichSchema(definition.schema)
// If an invalid sort column is specified, delete it
if (this.options.sortColumn && !schema[this.options.sortColumn]) {
this.options.sortColumn = null
@ -374,11 +374,7 @@ export default abstract class DataFetch<
* @param schema the datasource schema
* @return {object} the enriched datasource schema
*/
enrichSchema(schema: TableSchema | null): TableSchema | null {
if (schema == null) {
return null
}
private enrichSchema(schema: TableSchema): TableSchema {
// Check for any JSON fields so we can add any top level properties
let jsonAdditions: Record<string, { type: string; nestedJSON: true }> = {}
for (const fieldKey of Object.keys(schema)) {
@ -510,7 +506,7 @@ export default abstract class DataFetch<
* @param state the current store state
* @return {boolean} whether there is a next page of data or not
*/
hasNextPage(state: DataFetchStore<TDefinition, TQuery>): boolean {
private hasNextPage(state: DataFetchStore<TDefinition, TQuery>): boolean {
return state.cursors[state.pageNumber + 1] != null
}
@ -520,7 +516,7 @@ export default abstract class DataFetch<
* @param state the current store state
* @return {boolean} whether there is a previous page of data or not
*/
hasPrevPage(state: { pageNumber: number }): boolean {
private hasPrevPage(state: { pageNumber: number }): boolean {
return state.pageNumber > 0
}

View File

@ -28,10 +28,7 @@ export default class ViewV2Fetch extends DataFetch<UIView, ViewV2> {
}
}
getDefaultSortColumn(
_definition: { primaryDisplay?: string } | null,
_schema: Record<string, any>
) {
getDefaultSortColumn() {
return null
}