11import React from 'react' ;
22
3- import { skipToken } from '@reduxjs/toolkit/query' ;
4-
53import { ResizeableDataTable } from '../../../../components/ResizeableDataTable/ResizeableDataTable' ;
64import { TableSkeleton } from '../../../../components/TableSkeleton/TableSkeleton' ;
75import { overviewApi } from '../../../../store/reducers/overview/overview' ;
@@ -42,23 +40,28 @@ export const SchemaViewer = ({type, path, tenantName, extended = false}: SchemaV
4240 // Refresh table only in Diagnostics
4341 const pollingInterval = extended ? autoRefreshInterval : undefined ;
4442
45- const { currentData : schemaData , isLoading : loading } = overviewApi . useGetOverviewQuery (
46- { path, database : tenantName } ,
47- { pollingInterval} ,
48- ) ;
49-
50- const viewSchemaRequestParams = isViewType ( type ) ? { path, database : tenantName } : skipToken ;
51-
52- const { data : viewColumnsData , isLoading : isViewSchemaLoading } =
53- viewSchemaApi . useGetViewSchemaQuery ( viewSchemaRequestParams , { pollingInterval} ) ;
43+ const { currentData : tableSchemaData , isFetching : isTableSchemaFetching } =
44+ overviewApi . useGetOverviewQuery (
45+ { path, database : tenantName } ,
46+ { pollingInterval, skip : isViewType ( type ) } ,
47+ ) ;
48+ const { currentData : viewColumnsData , isFetching : isViewSchemaFetching } =
49+ viewSchemaApi . useGetViewSchemaQuery (
50+ { path, database : tenantName } ,
51+ { pollingInterval, skip : ! isViewType ( type ) } ,
52+ ) ;
53+
54+ const loading =
55+ ( isViewSchemaFetching && viewColumnsData === undefined ) ||
56+ ( isTableSchemaFetching && tableSchemaData === undefined ) ;
5457
5558 const tableData = React . useMemo ( ( ) => {
5659 if ( isViewType ( type ) ) {
5760 return prepareViewSchema ( viewColumnsData ) ;
5861 }
5962
60- return prepareSchemaData ( type , schemaData ) ;
61- } , [ schemaData , type , viewColumnsData ] ) ;
63+ return prepareSchemaData ( type , tableSchemaData ) ;
64+ } , [ tableSchemaData , type , viewColumnsData ] ) ;
6265
6366 const hasAutoIncrement = React . useMemo ( ( ) => {
6467 return tableData . some ( ( i ) => i . autoIncrement ) ;
@@ -85,7 +88,7 @@ export const SchemaViewer = ({type, path, tenantName, extended = false}: SchemaV
8588 return [ ] ;
8689 } , [ type , extended , hasAutoIncrement , hasDefaultValue , tableData ] ) ;
8790
88- if ( loading || isViewSchemaLoading ) {
91+ if ( loading ) {
8992 return < TableSkeleton /> ;
9093 }
9194
0 commit comments