Skip to content

Commit 95d0f69

Browse files
jlobue10claude
andcommitted
Report preview availability from the verification state, not the render path
Every preview-mode tile reported into the shared store, but the verdict was derived from what the tile happened to draw: a compact tile for a non-image type and a document or model tile show a type icon without opening the iframe, so a file that failed to download still counted as available there, while the gallery card for the same NFT hit prepareError and reported it unavailable. Whichever tile mounted last won, and an autocomplete row could flip the gallery's verdict. The verdict now follows the verification state all of these tiles share: the preview is available when the selected source is verified and could be served from the cache, unavailable when there is no file, a settled mismatch, or a download failure — the same outcome the hash badge reports, whatever the tile draws. It stays undecided while verification is in flight and, for a failed data file, while the metadata has not settled, since a thumbnail may still verify. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YKEGodEgVdEuvUM8dza52q
1 parent b332522 commit 95d0f69

1 file changed

Lines changed: 20 additions & 14 deletions

File tree

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

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -516,30 +516,36 @@ export default function NFTPreview(props: NFTPreviewProps) {
516516
!icon &&
517517
![FileType.MODEL, FileType.DOCUMENT].includes(previewFileType);
518518

519-
// What the tile settled on showing — the same decision the render below
520-
// makes — so the gallery's preview filter classifies NFTs exactly as their
521-
// tiles do. Undefined while the tile is still loading.
519+
// The verdict behind the gallery's preview filter. It follows the
520+
// verification state rather than the render path: a document or model
521+
// tile draws its type icon even when the file could not be fetched, and a
522+
// compact tile never opens the iframe, yet the file is just as unavailable
523+
// (the hash badge says so) — so every preview-mode tile of an NFT reaches
524+
// the same verdict, whichever of them happens to mount. Undefined while
525+
// anything that could still change the verdict is in flight.
522526
const previewStatus = useMemo(() => {
523-
if (isLoading) {
527+
if (isLoading || isLoadingVerifyHash) {
524528
return undefined;
525529
}
526530

527-
if (!hasFile || isHashMismatch) {
528-
return NFTPreviewStatus.UNAVAILABLE;
531+
if (!preview?.isVerified) {
532+
// no file, a settled mismatch, or a file that failed to download — but
533+
// a thumbnail in metadata that has not arrived yet may still verify
534+
return isLoadingMetadata ? undefined : NFTPreviewStatus.UNAVAILABLE;
529535
}
530536

531-
if (usesIframe) {
532-
if (prepareError) {
533-
return NFTPreviewStatus.UNAVAILABLE;
534-
}
537+
if (prepareError) {
538+
// the verified file could not be served from the cache
539+
return NFTPreviewStatus.UNAVAILABLE;
540+
}
535541

536-
if (!previewContent) {
537-
return undefined;
538-
}
542+
if (!previewContent) {
543+
// preparePreview has not settled on this uri yet
544+
return undefined;
539545
}
540546

541547
return NFTPreviewStatus.AVAILABLE;
542-
}, [isLoading, hasFile, isHashMismatch, usesIframe, prepareError, previewContent]);
548+
}, [isLoading, isLoadingVerifyHash, isLoadingMetadata, preview, prepareError, previewContent]);
543549

544550
useEffect(() => {
545551
// Only preview-mode tiles report: the detail view verifies the full data

0 commit comments

Comments
 (0)