Open oytuncoban opened 1 year ago
I've this for a long time and now it's possible:
https://github.com/neu-fi/regen-bingo/issues/65
I'll mark this as non-urgent as it's a performance enhancement for a small number of cases. OTOH, it's likely that this issue will take a long time.
Some ideas:
For this to work, we should keep map from card ids to card objects like:
cardIdstoCards = {
515: Card,
293: Card,
48: Card
}
When cards are set, there should be a map created from numbers to cards containing them like below:
numbersToCardIds = {
1: [],
2: [515],
3: [],
4: [293],
...
89: [293, 515]
90: [48]
}
And an order array for IDs: sortedCardIds = [293,48,515]
Network/account change Mint and Transfer events update cardIdsToCards
.
Changes in cardIdsToCards
updates numbersToCardIds
and sortedCardIds
.
NumberDrawn events are watched, update relevant cardIdstoCards
.
The frontend renders the list of sortedCardIds
with data in cardIdstoCards
.
However, it's not a good practice to chain useEffects. This can have a worse performance.
When a number is drawn, we should update tokenURI's of only the tokens that have that specific number.