Skip to content

Commit 4d61e77

Browse files
jlobue10claude
andcommitted
Show verified previews while metadata is still downloading
A slow or dead metadata host kept gallery and offer tiles on a loading spinner (and the hash status badge on 'Verifying hash...') even after the data file had been downloaded and its hash verified. Metadata now only holds the tile in the loading state while there is no verified preview to show, and the verify hook stops reporting loading once the data verification outcome - the only input to isVerified - has settled. Because the sensitive-content flag lives in the metadata, a preview rendered before the metadata settles stays covered until the flag can be read, so hideObjectionableContent never flashes unblurred content. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016Q2tBCuePZJeeCkDDxu1m3
1 parent 5180bb4 commit 4d61e77

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

packages/gui/src/components/nfts/NFTPreview.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,20 @@ export default function NFTPreview(props: NFTPreviewProps) {
172172

173173
const { isLoading: isLoadingNFT } = useNFT(nftId);
174174
const { metadata, isLoading: isLoadingMetadata } = useNFTMetadata(nftId);
175-
// hash verification downloads the full data file, which can take a long time
176-
// for large media — only wait for it while there is no preview uri to show yet
177-
const isLoading = isLoadingMetadata || isLoadingNFT || isLoadingFileType || (isLoadingVerifyHash && !preview);
175+
// hash verification downloads the full data file, which can take a long
176+
// time for large media, and the metadata host can be slow or dead — either
177+
// one only blocks the tile while there is no verified preview uri to show
178+
const isLoading = isLoadingNFT || isLoadingFileType || ((isLoadingVerifyHash || isLoadingMetadata) && !preview);
178179

179180
const blurPreview = useMemo(() => {
180181
if (!hideObjectionableContent) {
181182
return false;
182183
}
183184

184-
if (isLoading) {
185-
return false;
185+
// a verified preview can render before the metadata fetch settles — keep
186+
// it covered until the sensitive-content flag can actually be read
187+
if (isLoadingMetadata) {
188+
return true;
186189
}
187190

188191
if (!metadata) {
@@ -194,7 +197,7 @@ export default function NFTPreview(props: NFTPreviewProps) {
194197
}
195198

196199
return false;
197-
}, [hideObjectionableContent, isLoading, metadata]);
200+
}, [hideObjectionableContent, isLoadingMetadata, metadata]);
198201

199202
const previewExtension = useMemo(() => getFileExtension(preview?.uri), [preview]);
200203

packages/gui/src/hooks/useNFTVerifyHash.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ export default function useNFTVerifyHash(nftId?: string, options: UseNFTVerifyHa
3333
const [previewImage, setPreviewImage] = useState<NFTPreviewState | undefined>();
3434
const verificationGeneration = useRef(0);
3535

36-
const isLoading = isLoadingNFT || isLoadingMetadata || isVerifying;
36+
// A pending metadata download only blocks the result while there is no
37+
// data verification outcome yet: `isVerified` is derived from the data
38+
// file alone, so once it settles a slow or dead metadata host must not
39+
// keep consumers (gallery tiles, hash status badges) in a loading state.
40+
const isLoading = isLoadingNFT || isVerifying || (isLoadingMetadata && !data);
3741
const error = errorNFT || errorMetadata || errorVerify;
3842

3943
const findValidUri = useCallback(

0 commit comments

Comments
 (0)