Skip to content
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

Simplify query generation #439

Merged
merged 1 commit into from May 25, 2023
Merged

Conversation

csillag
Copy link
Contributor

@csillag csillag commented May 25, 2023

Instead of manually enumerating all possible combinations of networks and runtimes, creating queries for them, and then checking if they are enabled, we can just compile the list of enabled combinations, and generated queries just for them.

Doing this simplifies our code. (And now we can add more networks and runtimes without manually having to touch this code.)

Normally, calling React hooks from callbacks and other conditional code is not a good idea, but in this case, we can be sure that the number of enabled combinations will never change during runtime (since it's hard-coded in route-utils.ts), su we can just ignore the TS warning about abusing the rules of hooks.

@github-actions
Copy link

github-actions bot commented May 25, 2023

Deployed to Cloudflare Pages

Latest commit: 465a8de4469846a297887f10c95a6b6d0b650c33
Status:✅ Deploy successful!
Preview URL: https://c8940261.oasis-explorer.pages.dev

Copy link
Member

@lukaw3d lukaw3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright

@csillag csillag force-pushed the csillag/simplify-query-generation branch from 95cf00c to 46505cf Compare May 25, 2023 20:19
Instead of manually enumerating all possible combinations of networks
and runtimes, creating queries for them, and then checking if they are
enabled, we can just compile the list of enabled combinations, and
generated queries just for them.

Doing this simplifies our code. (And now we can add more networks
and runtimes without manually having to touch this code.)

Normally, calling React hooks from callbacks and other conditional code
is not a good idea, but in this case, we can be sure that the number of
enabled combinations will never change during runtime
(since it's hard-coded in route-utils.ts), su we can just ignore
the TS warning about abusing the rules of hooks.
@csillag csillag force-pushed the csillag/simplify-query-generation branch from 46505cf to 465a8de Compare May 25, 2023 20:29
@csillag csillag merged commit bec5270 into master May 25, 2023
4 checks passed
@csillag csillag deleted the csillag/simplify-query-generation branch May 25, 2023 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants