-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ref: Migrate useBranchCoverageMeasurements to TSQ V5 #3711
Changes from 4 commits
113fb53
fd4828f
5f6cdbf
5812194
f1b7e75
f3c5586
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { keepPreviousData } from '@tanstack/react-queryV5' | ||
import { format } from 'date-fns' | ||
import { useParams } from 'react-router-dom' | ||
import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from 'recharts' | ||
|
@@ -43,17 +44,16 @@ function CoverageChart() { | |
defaultBranch: overview?.defaultBranch ?? '', | ||
}) | ||
|
||
const { data, isPreviousData, isLoading, isError } = | ||
const { data, isPlaceholderData, isPending, isError } = | ||
useRepoCoverageTimeseries({ | ||
branch: selection?.name, | ||
options: { | ||
enabled: !!selection?.name, | ||
suspense: false, | ||
keepPreviousData: true, | ||
placeholderData: keepPreviousData, | ||
}, | ||
}) | ||
|
||
if (!isPreviousData && isLoading) { | ||
if (!isPlaceholderData && isPending) { | ||
return <Placeholder /> | ||
} | ||
|
||
|
@@ -65,7 +65,7 @@ function CoverageChart() { | |
) | ||
} | ||
|
||
if (data?.measurements.length < 1) { | ||
if (!isPending && data?.measurements?.length < 1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need !isPending here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, if it's not included then there's a type error There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hrmrm, actually gonna switch this up a little bit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay tidied things up There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! love it |
||
return ( | ||
<div className="flex min-h-[250px] items-center justify-center xl:min-h-[380px]"> | ||
<p className="text-center"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The optional chains are kinda throwing me off here because we're doing a hard set on the values in the line below 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is validating that there is an entry in the array that has a field
max
on it that isnull
so that we can override the value. You're not able to use optional chaining while assigning a value.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep I get that, it's a little unclear bc we're checking for null explicitly whereas if the value doesn't exist at any other point it'd return undefined. Just one of those "gotchas" / "landmines"