@@ -35,7 +35,23 @@ export default function useNFTVerifyHash(nftId?: string, options: UseNFTVerifyHa
3535 const dataGeneration = useRef ( 0 ) ;
3636 const previewGeneration = useRef ( 0 ) ;
3737
38- const isVerifying = isVerifyingData || isVerifyingPreview ;
38+ // The inputs the preview effect last picked up. `isVerifyingPreview` is set
39+ // inside that effect, which runs only after the render has painted, so on
40+ // the frame where the metadata first arrives it still reads false — and an
41+ // already-verified data file would win the preview slot for that one frame
42+ // before the swap. Comparing the current inputs against this ref makes that
43+ // frame count as verifying synchronously.
44+ const previewInputs = useRef < { nft ?: NFTInfo ; metadata ?: Metadata } > ( { } ) ;
45+
46+ const settledMetadata = isLoadingMetadata ? undefined : metadata ;
47+ const isPreviewPassPending =
48+ preview &&
49+ ! ! nft &&
50+ ! isLoadingNFT &&
51+ ! ! settledMetadata &&
52+ ( previewInputs . current . nft !== nft || previewInputs . current . metadata !== settledMetadata ) ;
53+
54+ const isVerifying = isVerifyingData || isVerifyingPreview || isPreviewPassPending ;
3955
4056 // A pending metadata download only blocks the result while there is no
4157 // data verification outcome yet: `isVerified` is derived from the data
@@ -182,6 +198,7 @@ export default function useNFTVerifyHash(nftId?: string, options: UseNFTVerifyHa
182198 // verifies the data file right away, and this effect picks up the preview
183199 // URIs once the metadata fetch settles, instead of blocking on it.
184200 const nftMetadata = isLoadingMetadata ? undefined : metadata ;
201+ previewInputs . current = { nft : ! isLoadingNFT ? nft : undefined , metadata : nftMetadata } ;
185202 if ( ! preview || ! nft || isLoadingNFT || ! nftMetadata ) {
186203 setIsVerifyingPreview ( false ) ;
187204 } else {
0 commit comments