fudgebucket27 / Lexplorer

Loopring explorer alternative
14 stars 10 forks source link

Separated NFT grid #195

Closed modersohn closed 2 years ago

modersohn commented 2 years ago

Closes #193

Wow, that has been quite a ride, lots of new things learnt, but I think I got everything! Cancellation etc. work, directly changing page numbers via the URL etc. all still seem to work just fine!

No visual changes AFAICS.

The grid needs to have a list of AccountNFTSlot, not NonFungibleToken, for it to display the balance - when viewing on AccountDetails. For the collection view, a LINQ transformation of the list is therefore necessary, but I don't think that'll hurt.

Please give it a thorough test drive on dev.

Now that this is separated out, we can tackle #180

modersohn commented 2 years ago

We should wait with merging this into production!

I've just found out that, because the NFTGrid is now a child component, it's OnParameterSetAsync is called way more often, even if parameters actually didn't change. (This is an interesting read BTW https://www.thinktecture.com/blazor/blazor-components-lifecycle-is-not-always-straightforward/)

That is problematic, because every new call to OnParameterSetAsync will cancel the cancellationToken from the previous run. This is visible in the console with "tons" of Request aborted messages and that also means we're cancelling many RestRequests and then immediately do them again. To see that in action, change the page while the NFTs are still loading. I would expect one Request aborted as we're only fetching one at a time - but I see 5 or 6.

fudgebucket27 commented 2 years ago

Ahhhh I didn't notice that in the console. Thanks for the heads up then.