mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 01:47:00 +01:00
NFTs: Use Unknown Collection instead of first NFT name (#18388)
* NFTs: Use Unknown Collection instead of first NFT name * Use localization in hook * Get localization for previously owned * Fix tests --------- Co-authored-by: Dan Miller <danjm.com@gmail.com>
This commit is contained in:
parent
26fed9e8da
commit
e895ff33f9
3
app/_locales/en/messages.json
generated
3
app/_locales/en/messages.json
generated
@ -2309,6 +2309,9 @@
|
||||
"nfts": {
|
||||
"message": "NFTs"
|
||||
},
|
||||
"nftsPreviouslyOwned": {
|
||||
"message": "Previously Owned"
|
||||
},
|
||||
"nickname": {
|
||||
"message": "Nickname"
|
||||
},
|
||||
|
@ -51,7 +51,7 @@ describe('Import ERC1155 NFT', function () {
|
||||
// Check the imported ERC1155 and its image are displayed in the ERC1155 tab
|
||||
const importedERC1155 = await driver.waitForSelector({
|
||||
css: 'h5',
|
||||
text: 'Rocks',
|
||||
text: 'Unnamed collection',
|
||||
});
|
||||
assert.equal(await importedERC1155.isDisplayed(), true);
|
||||
|
||||
|
@ -4,11 +4,16 @@ import { isEqual } from 'lodash';
|
||||
import { getNfts, getNftContracts } from '../ducks/metamask/metamask';
|
||||
import { getCurrentChainId, getSelectedAddress } from '../selectors';
|
||||
import { usePrevious } from './usePrevious';
|
||||
import { useI18nContext } from './useI18nContext';
|
||||
|
||||
export function useNftsCollections() {
|
||||
const t = useI18nContext();
|
||||
const previouslyOwnedText = t('nftsPreviouslyOwned');
|
||||
const unknownCollectionText = t('unknownCollection');
|
||||
|
||||
const [collections, setCollections] = useState({});
|
||||
const [previouslyOwnedCollection, setPreviouslyOwnedCollection] = useState({
|
||||
collectionName: 'Previously Owned',
|
||||
collectionName: previouslyOwnedText,
|
||||
nfts: [],
|
||||
});
|
||||
const nfts = useSelector(getNfts);
|
||||
@ -19,6 +24,7 @@ export function useNftsCollections() {
|
||||
const prevNfts = usePrevious(nfts);
|
||||
const prevChainId = usePrevious(chainId);
|
||||
const prevSelectedAddress = usePrevious(selectedAddress);
|
||||
|
||||
useEffect(() => {
|
||||
const getCollections = () => {
|
||||
setNftsLoading(true);
|
||||
@ -27,7 +33,7 @@ export function useNftsCollections() {
|
||||
}
|
||||
const newCollections = {};
|
||||
const newPreviouslyOwnedCollections = {
|
||||
collectionName: 'Previously Owned',
|
||||
collectionName: previouslyOwnedText,
|
||||
nfts: [],
|
||||
};
|
||||
|
||||
@ -41,7 +47,7 @@ export function useNftsCollections() {
|
||||
({ address }) => address === nft.address,
|
||||
);
|
||||
newCollections[nft.address] = {
|
||||
collectionName: collectionContract?.name || nft.name,
|
||||
collectionName: collectionContract?.name || unknownCollectionText,
|
||||
collectionImage: collectionContract?.logo || nft.image,
|
||||
nfts: [nft],
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user