1
1
import React from 'react' ;
2
2
3
- import { skipToken } from '@reduxjs/toolkit/query' ;
4
-
5
3
import { ResizeableDataTable } from '../../../../components/ResizeableDataTable/ResizeableDataTable' ;
6
4
import { TableSkeleton } from '../../../../components/TableSkeleton/TableSkeleton' ;
7
5
import { overviewApi } from '../../../../store/reducers/overview/overview' ;
@@ -42,23 +40,28 @@ export const SchemaViewer = ({type, path, tenantName, extended = false}: SchemaV
42
40
// Refresh table only in Diagnostics
43
41
const pollingInterval = extended ? autoRefreshInterval : undefined ;
44
42
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 ) ;
54
57
55
58
const tableData = React . useMemo ( ( ) => {
56
59
if ( isViewType ( type ) ) {
57
60
return prepareViewSchema ( viewColumnsData ) ;
58
61
}
59
62
60
- return prepareSchemaData ( type , schemaData ) ;
61
- } , [ schemaData , type , viewColumnsData ] ) ;
63
+ return prepareSchemaData ( type , tableSchemaData ) ;
64
+ } , [ tableSchemaData , type , viewColumnsData ] ) ;
62
65
63
66
const hasAutoIncrement = React . useMemo ( ( ) => {
64
67
return tableData . some ( ( i ) => i . autoIncrement ) ;
@@ -85,7 +88,7 @@ export const SchemaViewer = ({type, path, tenantName, extended = false}: SchemaV
85
88
return [ ] ;
86
89
} , [ type , extended , hasAutoIncrement , hasDefaultValue , tableData ] ) ;
87
90
88
- if ( loading || isViewSchemaLoading ) {
91
+ if ( loading ) {
89
92
return < TableSkeleton /> ;
90
93
}
91
94
0 commit comments