Skip to content

Commit

Permalink
feat: apply useIssueExtraDetails to treeDetailsLazyLoaded
Browse files Browse the repository at this point in the history
Part of #870
  • Loading branch information
MarceloRobert committed Feb 13, 2025
1 parent a236fa4 commit 6cab87c
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions dashboard/src/hooks/useTreeDetailsLazyLoadQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import type {
TreeDetailsSummary,
} from '@/types/tree/TreeDetails';
import type { QuerySelectorStatus } from '@/components/QuerySwitcher/QuerySwitcher';
import { useIssueExtraDetails } from '@/api/issueExtras';
import type { IssueExtraDetailsResponse } from '@/types/issueExtras';

export type TreeDetailsLazyLoaded = {
summary: {
Expand All @@ -21,6 +23,12 @@ export type TreeDetailsLazyLoaded = {
isLoading: boolean;
status: QuerySelectorStatus;
};
issuesExtras: {
data?: IssueExtraDetailsResponse;
isLoading: boolean;
status: QuerySelectorStatus;
error: UseQueryResult['error'];
};
common: {
isAllReady: boolean;
isAnyLoading: boolean;
Expand All @@ -41,6 +49,13 @@ export const useTreeDetailsLazyLoadQuery = (
enabled: !!summaryResult.data,
});

const issuesExtrasResult = useIssueExtraDetails({
buildIssues: summaryResult.data?.summary.builds.issues,
bootIssues: summaryResult.data?.summary.boots.issues,
testIssues: summaryResult.data?.summary.tests.issues,
enabled: !!summaryResult.data,
});

return {
summary: {
data: summaryResult.data,
Expand All @@ -54,9 +69,18 @@ export const useTreeDetailsLazyLoadQuery = (
isLoading: fullResult.isLoading,
status: fullResult.status,
},
issuesExtras: {
data: issuesExtrasResult.data,
isLoading: issuesExtrasResult.isLoading,
status: issuesExtrasResult.status,
error: issuesExtrasResult.error,
},
common: {
isAllReady: !!summaryResult && !!fullResult,
isAnyLoading: summaryResult.isLoading || fullResult.isLoading,
isAllReady: !!summaryResult && !!fullResult && !!issuesExtrasResult,
isAnyLoading:
summaryResult.isLoading ||
fullResult.isLoading ||
issuesExtrasResult.isLoading,
},
};
};

0 comments on commit 6cab87c

Please sign in to comment.