Skip to content

Commit a3a68f5

Browse files
committed
fix: better code
1 parent dc23319 commit a3a68f5

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/containers/Tenant/Diagnostics/TenantOverview/TenantDashboard/TenantDashboard.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ interface TenantDashboardProps {
3131
export const TenantDashboard = ({database, charts}: TenantDashboardProps) => {
3232
const graphShardExists = useGraphShardExists();
3333

34-
// If GraphShardExists capability is true, show dashboard immediately
35-
// Otherwise, fall back to reactive behavior (hidden until first chart succeeds)
36-
const [isDashboardHidden, setIsDashboardHidden] = React.useState<boolean>(
37-
graphShardExists !== true,
38-
);
34+
const [hasSuccessfulChart, setHasSuccessfulChart] = React.useState<boolean>(false);
35+
36+
const isDashboardHidden = React.useMemo(() => {
37+
return graphShardExists !== true && !hasSuccessfulChart;
38+
}, [graphShardExists, hasSuccessfulChart]);
39+
3940
const [autoRefreshInterval] = useAutoRefreshInterval();
4041

4142
// Refetch data only if dashboard successfully loaded
@@ -54,7 +55,7 @@ export const TenantDashboard = ({database, charts}: TenantDashboardProps) => {
5455
const handleChartDataStatusChange = (chartStatus: ChartDataStatus) => {
5556
// Only use reactive behavior when GraphShardExists capability is not true
5657
if (graphShardExists !== true && chartStatus === 'success') {
57-
setIsDashboardHidden(false);
58+
setHasSuccessfulChart(true);
5859
}
5960
};
6061

0 commit comments

Comments
 (0)