File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
entities/campaign/components Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -368,7 +368,13 @@ export const useCampaigns = ({
368368export const useCampaign = ( { campaignId } : { campaignId : number } ) => {
369369 const queryResult = generatedClient . useV1CampaignsRetrieve2 ( campaignId , {
370370 ...currentNetworkConfig ,
371- swr : { enabled : true } ,
371+ swr : {
372+ enabled : true ,
373+ refreshInterval : 3000 ,
374+ // Retry on error (handles race condition when campaign is just created but not yet indexed)
375+ errorRetryCount : 10 ,
376+ errorRetryInterval : 2000 ,
377+ } ,
372378 } ) ;
373379
374380 return { ...queryResult , data : queryResult . data ?. data } ;
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ export const CampaignBanner: React.FC<CampaignBannerProps> = ({ campaignId }) =>
3232 const {
3333 data : campaign ,
3434 isLoading : isCampaignLoading ,
35+ isValidating : isCampaignValidating ,
3536 error : campaignLoadingError ,
3637 } = indexer . useCampaign ( { campaignId } ) ;
3738
@@ -78,7 +79,18 @@ export const CampaignBanner: React.FC<CampaignBannerProps> = ({ campaignId }) =>
7879 [ raisedAmountFloat , token ?. usdPrice ] ,
7980 ) ;
8081
81- if ( campaignLoadingError ) {
82+ // Show loading state while retrying (handles race condition when campaign is just created but not yet indexed)
83+ if ( campaignLoadingError && isCampaignValidating ) {
84+ return (
85+ < div className = "flex h-40 flex-col items-center justify-center gap-2" >
86+ < Spinner className = "h-7 w-7" />
87+ < p className = "text-sm text-gray-500" > Loading campaign...</ p >
88+ </ div >
89+ ) ;
90+ }
91+
92+ // Only show error after retries are exhausted
93+ if ( campaignLoadingError && ! isCampaignValidating ) {
8294 return < h1 > Error Loading Campaign</ h1 > ;
8395 }
8496
You can’t perform that action at this time.
0 commit comments