From 4b6be6da0cf874b6a518cac4e5074d1a9b8e4567 Mon Sep 17 00:00:00 2001 From: claudiaHash <49017601+claudiaHash@users.noreply.github.com> Date: Mon, 31 Jan 2022 15:15:52 +0200 Subject: [PATCH] Invalid transction link fix (#1035) * get nft updates fix * fix * use nft update type * message case fixed * update message fix Co-authored-by: ClaudiaHolhos --- .../Asset/AssetContent/EditHistory.tsx | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/components/Asset/AssetContent/EditHistory.tsx b/src/components/Asset/AssetContent/EditHistory.tsx index 3a48730d7..4b139e98e 100644 --- a/src/components/Asset/AssetContent/EditHistory.tsx +++ b/src/components/Asset/AssetContent/EditHistory.tsx @@ -10,13 +10,17 @@ import styles from './EditHistory.module.css' const getReceipts = gql` query ReceiptData($address: ID!) { nftUpdates( - where: { id: $address } + where: { nft: $address } orderBy: timestamp orderDirection: desc ) { id + nft { + address + } tx timestamp + type } } ` @@ -24,6 +28,20 @@ const getReceipts = gql` export default function EditHistory(): ReactElement { const { ddo } = useAsset() + function getUpdateType(type: string): string { + switch (type) { + case 'METADATA_CREATED': + return 'published' + case 'METADATA_UPDATED': + return 'updated' + case 'STATE_UPDATED': + return 'state updated' + case 'TOKENURI_UPDATED': + return 'NFT metadata updated' + default: + return '' + } + } // // 1. Construct subgraph query based on DDO. // Need to wait for it to avoid infinite rerender loop with useQuery. @@ -39,7 +57,7 @@ export default function EditHistory(): ReactElement { const [result] = useQuery({ query: getReceipts, - variables: { address: ddo?.services[0].datatokenAddress.toLowerCase() }, + variables: { address: ddo?.nft.address.toLowerCase() }, context: queryContext, pause: !ddo || !queryContext }) @@ -49,18 +67,10 @@ export default function EditHistory(): ReactElement { // 2. Construct display data based on fetched data. // const [receipts, setReceipts] = useState() - const [creationTx, setCreationTx] = useState() useEffect(() => { if (!data || data.nftUpdates.length === 0) return - - const receiptCollectionLength = data.nftUpdates.length - const creationData = data.nftUpdates[receiptCollectionLength - 1] - setCreationTx(creationData.tx) - - const receiptCollection = [...data.nftUpdates] - receiptCollection.splice(-1, 1) - + const receiptCollection = data.nftUpdates setReceipts(receiptCollection) }, [data]) @@ -71,15 +81,11 @@ export default function EditHistory(): ReactElement { {receipts?.map((receipt) => (
  • - edited
  • ))} -
  • - - published -
  • )