-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Order pools on Dashboard by Investment Capacity #325
Conversation
🚀 Deployed on https://pr-325--dev-tinlake.netlify.app |
tinlake-ui/ducks/pools.ts
Outdated
const updatesPerPool: any = {} | ||
Object.entries(multicallData).forEach(([type, value]) => { | ||
const poolId = type.split('.')[0] | ||
const key = type.split('.')[1] | ||
if (!(poolId in updatesPerPool)) updatesPerPool[poolId] = {} | ||
updatesPerPool[poolId][key] = value | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was toying around with reduce so that this can be a "pure" operation rather than declaring an object with any
and then adding stuff to it. Do you think this any better?
const updatesPerPool = Object.entries(multicallData).reduce(
(updates, [type, value]) => {
const [poolId, key] = type.split('.');
if (!(poolId in updates)) {
updates[poolId] = {};
}
updates[poolId][key] = value;
return updates;
},
{},
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice yeah would be better. Updated! Still needed any
inside the loop though but at least the result is typed better now.
const updatesPerPool: { [key: string]: State } = Object.entries(multicallData).reduce(
(updates: any, [type, value]) => {
const [poolId, key] = type.split('.')
if (!(poolId in updates)) {
updates[poolId] = {}
}
updates[poolId][key] = value
return updates
},
{}
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one comment, no blockers 👍
Now hides the pool list until the data from the subgraph and multicall have been fetched, because it needs the additional data to sort and otherwise the pools in the list jump around when it eventually gets sorted
Closes #322