Skip to content

Commit 0655644

Browse files
authored
Merge pull request #547 from PotLock/staging
Staging to prod
2 parents be748eb + b3019e1 commit 0655644

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/common/api/indexer/hooks.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,13 @@ export const useCampaigns = ({
368368
export 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 };

src/entities/campaign/components/CampaignBanner.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)