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

Update data sources and state #130

Merged
merged 22 commits into from
May 23, 2022
Merged

Update data sources and state #130

merged 22 commits into from
May 23, 2022

Conversation

whoabuddy
Copy link

@whoabuddy whoabuddy commented May 16, 2022

This PR aims to review and rewrite both the CityCoins UI auth management and user state.

The main goals are to:

  • implement the CityCoins API for all read-only data calls
  • use jotai atoms for state management across components
  • eliminate the "per-city" page by using "selected city" state instead

This will resolve a few open issues, speed up the load times, and create a more consistent experience that can be built on top of. Definitely still a WIP - collaborators are welcome!

Update: After trying out a few ways to approach data storage and transitions, patterns are emerging! The mining and stacking activity components are a great example of fetching, computing, and storing data. If the block height is updated then data is automatically fetched again.

There are definitely some optimizations to be had here, but it's a great start and will let me focus on the action pages to bring this back to life.

Done

  • finished variable/color selection for light/dark mode (not active/implemented)
  • rewrote auth system and user data using jotai atoms (issue: persist with refresh)
  • determine method/structure to fetch and store city data from API
  • determine method/structure to indicate city selection in UI
  • re-implement header logo
  • re-implement content router
  • implement rate limiting on all requests to avoid 429 errors
  • dashboard: mining claims
  • atom data doesn't persist on refresh (localStorage?)

Moved known issues to #129 to track for future PRs.

Fixes #126
Fixes #120
Fixes #117
Fixes #102

whoabuddy added 22 commits May 12, 2022 15:04
This starts implementing jotai for state management in place of a few different inherited patterns.

This fixes the connect and auth interactions, login state, and fetching data like account balances on the profile.

KNOWN ISSUE: login not persisting on refresh
The old structure had a page per city, then a page per action, and a container for each set of actions in components. This can be streamlined to be page -> actions, with each component getting rewritten from the bottom-up.
This also explores some new patterns for fetching data from the API, including some manual rate limiting and updates to useEffect() patterns with async functions. Once finalized all changes will be applied throughout.
In general, an atom should indicate whether it's loaded or not, then serve the data versus tryign to infer this from the data itself.
Now that the pattern is defined this can be ported over to other objects, but there are too many requests firing off against the API. Lots of 429s.
Very simple and straight-forward approach to throttling all requests through fetchJson() with configurable limits. Set to 4 requests every second, evenly-spaced for now.
This adds a pattern for fetching data from V1 or V2 contracts based on their relative configs, in an iterative manner that should support any number of contract versions.
This is close enough that we should be able to cut a testing release on dev, then push to main and keep iteratively adding new features.
This was surprisingly simple, thank you jotaigit add -A
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.

1 participant