Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/apps/review/src/lib/hooks/useFetchScreeningReview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,11 +701,11 @@ export function useFetchScreeningReview(): useFetchScreeningReviewProps {
error: fetchChallengeReviewsError,
isValidating: isValidatingChallengeReviews,
}: SWRResponse<BackendReview[], Error> = useSWR<BackendReview[], Error>(
`reviewBaseUrl/reviews/${challengeId}/${reviewerKey}`,
challengeId && (reviewerIds.length || shouldForceReviewFetch)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The change from using isPaused to conditionally setting the SWR key to undefined is a good approach to prevent unnecessary API calls. However, ensure that challengeId and reviewerIds are always correctly initialized before this point to avoid potential issues with undefined values.

? `reviewBaseUrl/reviews/${challengeId}/${reviewerKey}`
: undefined,
{
fetcher: () => fetchChallengeReviews(challengeId ?? ''),
isPaused: () => !challengeId
|| (!reviewerIds.length && !shouldForceReviewFetch),
},
)

Expand Down
Loading