-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a hidden debug page for spam NFTs (#1187)
* first draft * adding spam scores to mouseover, show collection id instead of nft id, added copy button * changing message grammar * removing console logs * remove a console log --------- Co-authored-by: David Suh <davidsuh@Davids-MacBook-Pro.local> Co-authored-by: Marshall T. Rose <mrose17@gmail.com>
- Loading branch information
1 parent
c432ce2
commit 03e2ccf
Showing
4 changed files
with
103 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import React, { useState } from "react"; | ||
import { NFT } from "./core"; | ||
import { Item, SelectableImageList } from "./SelectableImageList"; | ||
import { Button } from "../Button"; | ||
|
||
interface Props { | ||
startCall: boolean; | ||
nfts?: NFT[]; | ||
nft: NFT | null; | ||
setNft: (nft: NFT | null) => void; | ||
} | ||
|
||
const showSpamScore = (item: Item) => { | ||
return `${item.name} (${item.chain}) ${ | ||
item.collection?.spam_score | ||
? "Spam Score: " + `${item.collection.spam_score}` | ||
: "" | ||
}`; | ||
}; | ||
|
||
export const NFTDebugPanel: React.FC<Props> = ({ | ||
startCall, | ||
nfts = [], | ||
nft, | ||
setNft, | ||
}) => { | ||
const nftItems = nfts.map((n: NFT) => ({ ...n, imageUrl: n.image_url })); | ||
const [selectedNftIdxs, setSelectedNftIdxs] = useState<number[]>([]); | ||
const selectedNftsId = nfts | ||
.filter((n: NFT, index) => selectedNftIdxs.includes(index)) | ||
.map((n: NFT) => | ||
n.collection ? n.collection.collection_id : "no-collection-id" | ||
); | ||
const onToggle = (idx: number) => { | ||
if (selectedNftIdxs.includes(idx)) | ||
setSelectedNftIdxs(selectedNftIdxs.filter((i: number) => i != idx)); | ||
else { | ||
setSelectedNftIdxs(selectedNftIdxs.concat([idx])); | ||
} | ||
}; | ||
const copySelectedIdxs = () => { | ||
navigator.clipboard.writeText(selectedNftsId.join("\n")); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<div css={{ fontSize: "26px" }}>DEBUG MODE</div> | ||
<SelectableImageList | ||
items={nftItems} | ||
selectedIdxs={selectedNftIdxs} | ||
onToggleSelection={onToggle} | ||
onMouseOverText={showSpamScore} | ||
/> | ||
{selectedNftsId.map((s: string) => ( | ||
<div>{s}</div> | ||
))} | ||
<Button | ||
css={{ | ||
marginTop: "10px", | ||
}} | ||
onClick={copySelectedIdxs} | ||
> | ||
Copy Selected IDs | ||
</Button> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters