frontend: move web config access into config context/provider#3916
frontend: move web config access into config context/provider#3916smokyisthatyou wants to merge 29 commits into
Conversation
|
nice, please make one more change/commit. Currently each component still does a get request when using getConfig. Instead it could call getConfig once on startup and keep the "config" object in the context. getConfig could then either read out the local "config" object, or context could expose "config" object along with setConfig. I am not sure what is better. With this all components that depend on "config" object can read from the context without doing an additional api call. We want the source of truth still to be the backend, so in the context it should update the "config" object after setConfig and fetch from the api. Also the api function in utils should be moved into frontends/web/src/api/config.ts |
|
concept ACK |
30401e1 to
ea60d60
Compare
ea60d60 to
4da6264
Compare
|
@thisconnect moving this from draft, rebased |
|
@thisconnect ptal whenever you have time 🙏 |
e991fa0 to
8fb8728
Compare
ed28dd9 to
925a212
Compare
|
@jadzeidan while working on this pr i think i introduced an old behaviour of the app that was opening the guide on first run. i implemented the code thinking it was the current expected flow, but @thisconnect pointed out this was actually deprecated in v4.40. personally i’m not a huge fan of the auto-opening guide for aesthetic reasons, though I can see the utility. |
|
thanks @smokyisthatyou for finding this 😄 I agree that guide shouldn't open automatically, so let's keep the "new" behaviour. |
d730016 to
cacf20f
Compare
cacf20f to
bd2bd6c
Compare
|
@thisconnect rebased |
📝 WalkthroughWalkthroughThis PR refactors the application's configuration management from a utility-based pattern to a React context-based system. A new typed API module ( ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Type known frontend/backend config keys in api/config, remove duplicate advanced-settings types and unsafe casts, tighten TConfigUpdate and normalization, and add mockConfig for unit tests.
this avoids calling getConfig/setConfig directly and redundant config fetches
Drop the onChangeConfig callback chain; children already update config via useConfig().
- Simplify darkmode unset spread in DarkmodeProvider - Remove redundant userLanguage cast in i18n detector after truthiness guard. - Align feetargets expertFee access with context nullability (direct frontend read in effect, optional config in render). - Simplify remember-wallet dialog config check to optional chaining.
0feada1 to
1e34610
Compare
type getConfig with required top-level keys; guard only undefined config (and nested fields like proxy) instead of optional frontend/backend objects.
thisconnect
left a comment
There was a problem hiding this comment.
very nice almost there
swap.tsx was recently merged, please also useConfig there instead of useLoad(getConfig)
| }; | ||
| let pendingConfig: TConfigUpdate = {}; | ||
|
|
||
| export const emptyBackendConfig = (): TConfig['backend'] => ({} as TConfig['backend']); |
There was a problem hiding this comment.
We trust the backend returns what is defined in api files.
c34305e to
3b2205d
Compare
Add ConfigContext + ConfigProvider in frontends/web and refactor React components/hooks to consume getConfig/setConfig through useConfig() instead of importing utils/config directly. Keep non-React config consumers on the shared utils/config implementation path, and update related hook dependency arrays.
Before asking for reviews, here is a check list of the most common things you might need to consider:
cc @thisconnect