Skip to content

Commit

Permalink
fix: adds updatePersistedCollections in setNftsForAccount
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeanribeiro authored and Tuditi committed May 22, 2024
1 parent 77f1965 commit e907885
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
let nftsToDownload: Nft[] = []
Expand Down Expand Up @@ -60,7 +60,7 @@ export async function loadNftsForAccount(account: IAccountState): Promise<Nft[]>
}
}
}
setNftsForAccount(account.index, accountNfts)
addOrUpdateNftsForAccount(account.index, accountNfts)

return accountNfts
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function updatePersistedCollections(nfts: Nft[]): Promise<void> {
const collectionsToAdd: PersistedCollection[] = []
for (const nft of nfts) {
if (!nft.collectionId || get(persistedCollections)[nft.collectionId]) {
return
continue
}

const collection = await buildPersistedCollectionFromNft(nft)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
)
}
}

Expand Down

0 comments on commit e907885

Please sign in to comment.