diff --git a/packages/datalib/src/GridConfig.ts b/packages/datalib/src/GridConfig.ts index 62f1d920f..427a7e7ae 100644 --- a/packages/datalib/src/GridConfig.ts +++ b/packages/datalib/src/GridConfig.ts @@ -18,6 +18,7 @@ export interface GridConfig extends GridConfigColumns { export interface GridCache { tables: { [uniqueName: string]: TableInfo }; + loadingTables: { schemaName: string; pureName: string }[]; refreshTime: number; } @@ -35,6 +36,7 @@ export function createGridConfig(): GridConfig { export function createGridCache(): GridCache { return { tables: {}, + loadingTables: [], refreshTime: new Date().getTime(), }; } diff --git a/packages/datalib/src/TableGridDisplay.ts b/packages/datalib/src/TableGridDisplay.ts index dc533bdac..8cb0756cd 100644 --- a/packages/datalib/src/TableGridDisplay.ts +++ b/packages/datalib/src/TableGridDisplay.ts @@ -162,9 +162,20 @@ export class TableGridDisplay extends GridDisplay { requireFkTarget(column: DisplayColumn) { const { uniqueName, foreignKey } = column; - this.getTableInfo({ schemaName: foreignKey.refSchemaName, pureName: foreignKey.refTableName }).then((table) => { + const pureName = foreignKey.refTableName; + const schemaName = foreignKey.refSchemaName; + if (this.cache.loadingTables.find((x) => x.pureName == pureName && x.schemaName == schemaName)) return; + + this.setCache((cache) => ({ + ...cache, + loadingTables: [...cache.loadingTables, { schemaName, pureName }], + })); + + this.getTableInfo({ schemaName, pureName }).then((table) => { + console.log('Loading table info', schemaName, pureName); this.setCache((cache) => ({ ...cache, + loadingTables: cache.loadingTables.filter((x) => x.schemaName != schemaName || x.pureName != pureName), tables: { ...cache.tables, [uniqueName]: table, @@ -173,7 +184,6 @@ export class TableGridDisplay extends GridDisplay { }); } - processReferences(select: Select, displayedColumnInfo: DisplayedColumnInfo): ReferenceActionResult { const action = combineReferenceActions( this.addJoinsFromExpandedColumns(select, this.columns, 'basetbl', displayedColumnInfo), diff --git a/packages/web/src/utility/usePropsCompare.js b/packages/web/src/utility/usePropsCompare.js index 2653e8a28..60ebd39d2 100644 --- a/packages/web/src/utility/usePropsCompare.js +++ b/packages/web/src/utility/usePropsCompare.js @@ -6,7 +6,7 @@ export default function usePropsCompare(props) { if (!prevProps) return; for (const key of _.union(_.keys(props), _.keys(prevProps))) { if (props[key] !== prevProps[key]) { - console.log(`Different prop value found: prop=${key}, old=${prevProps[key]}, new=${prevProps[key]}`); + console.log(`Different prop value found: prop=${key}, old, new`, prevProps[key], prevProps[key]); } } }