Skip to content

Commit

Permalink
tidy up the use of enabled opts
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-codecov committed Oct 31, 2024
1 parent 9db3a96 commit 833a3d0
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ const ModulesTable: React.FC<ModulesTableProps> = ({ asset }) => {
branch,
bundle,
asset,
opts: { enabled: bundle !== '' },
})

const tableData = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export function useBundleChartData({
'UNKNOWN_SIZE',
]

const { data: trendData, isLoading } = useQueryV5(
BundleTrendDataQueryOpts({
const { data: trendData, isLoading } = useQueryV5({
...BundleTrendDataQueryOpts({
provider,
owner,
repo,
Expand All @@ -84,9 +84,9 @@ export function useBundleChartData({
// temp removing while we don't have filtering by types implemented
// loadTypes: loadTypes,
},
enabled: !!overview?.oldestCommitAt,
})
)
}),
enabled: !!overview?.oldestCommitAt,
})

const mergedData = useMemo(() => {
const mergedDataMap = new Map<string, { [key: string]: number }>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ export const BundleDetails: React.FC = () => {
reportGroups: types,
loadTypes: loadTypes,
},
opts: { enabled: bundle !== '' },
})

if (!bundle || !summaryData || !summaryData.bundleSummary) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const query = `query BranchBundlesNames(
}
}
}`

interface BranchBundlesNamesQueryOptsArgs {
provider: string
owner: string
Expand Down
4 changes: 0 additions & 4 deletions src/services/bundleAnalysis/BundleTrendDataQueryOpts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ interface BundleTrendDataQueryOptsArgs {
// temp removing while we don't have filtering by types implemented
// loadTypes: Array<(typeof BUNDLE_LOAD_TYPE_ITEMS)[number]>
}
enabled?: boolean
suspense?: boolean
}

export const BundleTrendDataQueryOpts = ({
Expand All @@ -162,10 +160,8 @@ export const BundleTrendDataQueryOpts = ({
before,
after,
filters,
enabled,
}: BundleTrendDataQueryOptsArgs) =>
queryOptionsV5({
enabled: enabled,
queryKey: [
'GetBundleTrend',
provider,
Expand Down
6 changes: 1 addition & 5 deletions src/services/bundleAnalysis/useBranchBundleSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,13 @@ export interface BranchBundleSummaryQueryOptsArgs {
owner: string
repo: string
branch: string | null | undefined
repoOverviewIsSuccess: boolean
}

export const BranchBundleSummaryQueryOpts = ({
provider,
owner,
repo,
branch,
repoOverviewIsSuccess,
}: BranchBundleSummaryQueryOptsArgs) =>
queryOptionsV5({
queryKey: ['BranchBundleSummaryData', provider, owner, repo, branch],
Expand Down Expand Up @@ -200,7 +198,6 @@ export const BranchBundleSummaryQueryOpts = ({

return { branch }
}),
enabled: repoOverviewIsSuccess && typeof branch === 'string',
})

export interface UseBranchBundleSummaryArgs {
Expand All @@ -216,7 +213,7 @@ export const useBranchBundleSummary = ({
repo,
branch: branchArg,
}: UseBranchBundleSummaryArgs) => {
const { data: repoOverview, isSuccess } = useRepoOverview({
const { data: repoOverview } = useRepoOverview({
provider,
repo,
owner,
Expand All @@ -230,7 +227,6 @@ export const useBranchBundleSummary = ({
owner,
repo,
branch,
repoOverviewIsSuccess: isSuccess,
})
)
}
15 changes: 0 additions & 15 deletions src/services/bundleAnalysis/useBundleAssetModules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,6 @@ interface BundleAssetModulesQueryOptsArgs {
branch: string
bundle: string
asset: string
opts?: {
enabled?: boolean
}
}

export const BundleAssetModulesQueryOpts = ({
Expand All @@ -153,13 +150,7 @@ export const BundleAssetModulesQueryOpts = ({
branch,
bundle,
asset,
opts = {},
}: BundleAssetModulesQueryOptsArgs) => {
let enabled = true
if (opts.enabled) {
enabled = opts.enabled
}

return queryOptionsV5({
queryKey: [
'BundleAssetModules',
Expand Down Expand Up @@ -235,7 +226,6 @@ export const BundleAssetModulesQueryOpts = ({

return { modules }
}),
enabled: enabled,
})
}

Expand All @@ -246,9 +236,6 @@ interface UseBundleAssetModulesArgs {
branch: string
bundle: string
asset: string
opts?: {
enabled?: boolean
}
}

export const useBundleAssetModules = ({
Expand All @@ -258,7 +245,6 @@ export const useBundleAssetModules = ({
branch,
bundle,
asset,
opts = {},
}: UseBundleAssetModulesArgs) => {
return useSuspenseQueryV5(
BundleAssetModulesQueryOpts({
Expand All @@ -268,7 +254,6 @@ export const useBundleAssetModules = ({
branch,
bundle,
asset,
opts,
})
)
}
19 changes: 5 additions & 14 deletions src/services/bundleAnalysis/useBundleAssets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,6 @@ interface BundleAssetQueryOptsArgs {
}
orderingDirection?: OrderingDirection
ordering?: 'NAME' | 'SIZE' | 'TYPE'
opts?: {
enabled?: boolean
suspense?: boolean
}
}

export const BundleAssetsQueryOpts = ({
Expand All @@ -238,9 +234,6 @@ export const BundleAssetsQueryOpts = ({
filters = {},
orderingDirection,
ordering,
opts = {
enabled: true,
},
}: BundleAssetQueryOptsArgs) =>
infiniteQueryOptionsV5({
queryKey: [
Expand Down Expand Up @@ -353,7 +346,6 @@ export const BundleAssetsQueryOpts = ({
getNextPageParam: (data) => {
return data?.pageInfo?.hasNextPage ? data?.pageInfo?.endCursor : null
},
enabled: opts?.enabled !== undefined ? opts.enabled : true,
})

interface UseBundleAssetsArgs {
Expand All @@ -373,7 +365,6 @@ interface UseBundleAssetsArgs {
ordering?: 'NAME' | 'SIZE' | 'TYPE'
opts?: {
enabled?: boolean
suspense?: boolean
}
}

Expand All @@ -391,8 +382,8 @@ export const useBundleAssets = ({
ordering,
opts,
}: UseBundleAssetsArgs) => {
return useInfiniteQueryV5(
BundleAssetsQueryOpts({
return useInfiniteQueryV5({
...BundleAssetsQueryOpts({
provider,
owner,
repo,
Expand All @@ -404,7 +395,7 @@ export const useBundleAssets = ({
filters,
orderingDirection,
ordering,
opts,
})
)
}),
enabled: opts?.enabled,
})
}
10 changes: 0 additions & 10 deletions src/services/bundleAnalysis/useBundleSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ interface BundleSummaryQueryOptsArgs {
reportGroups?: string[]
loadTypes?: string[]
}
opts?: {
enabled?: boolean
}
}

export const BundleSummaryQueryOpts = ({
Expand All @@ -145,7 +142,6 @@ export const BundleSummaryQueryOpts = ({
branch,
bundle,
filters,
opts = {},
}: BundleSummaryQueryOptsArgs) =>
queryOptionsV5({
queryKey: ['BundleSummary', provider, owner, repo, branch, bundle, filters],
Expand Down Expand Up @@ -206,7 +202,6 @@ export const BundleSummaryQueryOpts = ({

return { bundleSummary }
}),
enabled: opts?.enabled,
})

interface UseBundleSummaryArgs {
Expand All @@ -219,9 +214,6 @@ interface UseBundleSummaryArgs {
reportGroups?: string[]
loadTypes?: string[]
}
opts?: {
enabled?: boolean
}
}

export const useBundleSummary = ({
Expand All @@ -231,7 +223,6 @@ export const useBundleSummary = ({
branch: branchParam,
bundle,
filters = {},
opts = {},
}: UseBundleSummaryArgs) => {
const { data: overview } = useRepoOverview({
provider,
Expand All @@ -252,7 +243,6 @@ export const useBundleSummary = ({
branch,
bundle,
filters,
opts,
})
)
}

0 comments on commit 833a3d0

Please sign in to comment.