diff --git a/packages/shared/src/lib/core/nfts/actions/loadNftsForActiveProfile.ts b/packages/shared/src/lib/core/nfts/actions/loadNftsForActiveProfile.ts index e8e269141f..aa178138a8 100644 --- a/packages/shared/src/lib/core/nfts/actions/loadNftsForActiveProfile.ts +++ b/packages/shared/src/lib/core/nfts/actions/loadNftsForActiveProfile.ts @@ -8,7 +8,7 @@ import { get } from 'svelte/store' import { Nft } from '../interfaces' import { addNftsToDownloadQueue } from './addNftsToDownloadQueue' import { buildNftFromNftOutput } from './buildNftFromNftOutput' -import { setNftsForAccount } from '../stores' +import { addOrUpdateNftsForAccount } from '../stores' export async function loadNftsForActiveProfile(): Promise { let nftsToDownload: Nft[] = [] @@ -60,7 +60,7 @@ export async function loadNftsForAccount(account: IAccountState): Promise } } } - setNftsForAccount(account.index, accountNfts) + addOrUpdateNftsForAccount(account.index, accountNfts) return accountNfts } diff --git a/packages/shared/src/lib/core/nfts/actions/updatePersistedCollections.ts b/packages/shared/src/lib/core/nfts/actions/updatePersistedCollections.ts index fd7ea52b8c..d6962a306d 100644 --- a/packages/shared/src/lib/core/nfts/actions/updatePersistedCollections.ts +++ b/packages/shared/src/lib/core/nfts/actions/updatePersistedCollections.ts @@ -7,7 +7,7 @@ export async function updatePersistedCollections(nfts: Nft[]): Promise { const collectionsToAdd: PersistedCollection[] = [] for (const nft of nfts) { if (!nft.collectionId || get(persistedCollections)[nft.collectionId]) { - return + continue } const collection = await buildPersistedCollectionFromNft(nft) diff --git a/packages/shared/src/lib/core/nfts/stores/active-profile-nfts-per-account.store.ts b/packages/shared/src/lib/core/nfts/stores/active-profile-nfts-per-account.store.ts index ba3dc2f727..0b178750d8 100644 --- a/packages/shared/src/lib/core/nfts/stores/active-profile-nfts-per-account.store.ts +++ b/packages/shared/src/lib/core/nfts/stores/active-profile-nfts-per-account.store.ts @@ -18,13 +18,6 @@ export function getNftsForAccount(accountIndex: number): Nft[] { return get(activeProfileNftsPerAccount)[accountIndex] ?? [] } -export function setNftsForAccount(accountIndex: number, nfts: Nft[]): void { - activeProfileNftsPerAccount.update((state) => { - state[accountIndex] = nfts - return state - }) -} - export function addOrUpdateNftsForAccount(accountIndex: number, nfts: Nft[]): void { const addedNfts: Nft[] = [] activeProfileNftsPerAccount.update((state) => { diff --git a/packages/shared/src/lib/core/nfts/utils/buildPersistedErc721Nft.ts b/packages/shared/src/lib/core/nfts/utils/buildPersistedErc721Nft.ts index 72dba9f29a..c6a9942fdf 100644 --- a/packages/shared/src/lib/core/nfts/utils/buildPersistedErc721Nft.ts +++ b/packages/shared/src/lib/core/nfts/utils/buildPersistedErc721Nft.ts @@ -54,7 +54,9 @@ export async function buildPersistedErc721Nft( persistedNft.mediaUrl = metadata.image } catch (err) { - throw new Error(`Unable to get metadata of token ${tokenId} from contract ${contractMetadata.address}`) + throw new Error( + `Unable to get metadata of token ${tokenId} from contract ${contractMetadata.address} due to: ${err}` + ) } }