Portfolio: keep editable defaults and auto-sync address from Farcaster username#1745
Portfolio: keep editable defaults and auto-sync address from Farcaster username#1745Jhonattan2121 wants to merge 3 commits intocanaryfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughFidgetWrapper gains configurable backfill via Changes
Sequence DiagramsequenceDiagram
participant User as User
participant Portfolio as Portfolio
participant UsernameInput as PortfolioUsernameInput
participant Neynar as NeynarService
participant FidgetWrapper as FidgetWrapper
User->>Portfolio: mount (props: data, saveData)
Portfolio->>Portfolio: resolve effective FID, signer, identities
Portfolio->>UsernameInput: render with current/derived username
User->>UsernameInput: enter/modify username
UsernameInput->>Neynar: fetch user & verifications
Neynar-->>UsernameInput: return user + addresses
UsernameInput->>Portfolio: updateSettings(farcasterUsername, walletAddresses)
Portfolio->>FidgetWrapper: saveData(lastFetchSettings) (if changed & backfill allowed)
Portfolio->>Portfolio: update iframe URL with resolved username/addresses
Portfolio-->>User: render iframe
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In `@src/common/fidgets/FidgetWrapper.tsx`:
- Around line 178-184: The useMemo that computes derivedSettings is missing
backfillOverrideKeys and noDefaultOverride in its dependency array, causing
stale values; update the dependency list for the derivedSettings memo (the
useMemo that references backfillOverrideKeys and noDefaultOverride) to include
both backfillOverrideKeys and noDefaultOverride alongside the existing
dependencies (zustandSettings, bundle.config.settings, lastFetchSettings,
defaultSettingsMap, disableBackfill) so the memo recalculates whenever those
values change.
In `@src/fidgets/token/Portfolio.tsx`:
- Around line 167-201: The effect in useEffect that computes shouldAuto
currently treats meta undefined as a username change and can overwrite a
manually provided walletAddresses; modify the shouldAuto logic in Portfolio.tsx
so auto-fill runs only when walletAddresses is empty or when the existing
address matches a previous auto-filled value: check meta?.autoAddressValue and
walletAddresses (the addressInput) and only set shouldAuto = true if
addressInput is falsy OR addressInput === meta?.autoAddressValue; keep username
change handling by comparing meta?.autoAddressUsername to effectiveUsername to
decide whether to refresh the auto value, and then call saveData with
autoAddressUsername/autoAddressValue/backfillOverrideKeys/lastFetchSettings as
before.
In `@src/fidgets/token/PortfolioUsernameInput.tsx`:
- Around line 41-51: The hook in PortfolioUsernameInput.tsx currently uses
lastAppliedRef to track only primaryAddress so changing the username
(normalized) to a different form (e.g., adding/removing "@") won’t reapply
updateSettings; change the check to track both normalized and primaryAddress
(e.g., store a combined key) or perform normalization inside the onChange
handler and set lastAppliedRef to the normalized username + address before
calling updateSettings so updateSettings({ farcasterUsername: normalized,
walletAddresses: primaryAddress }) runs whenever either value meaningfully
changes.
🧹 Nitpick comments (1)
src/common/components/organisms/FidgetSettingsEditor.tsx (1)
211-216: Centralize the Portfolio skip-defaults field list.The same field list is hard-coded here and in
src/common/fidgets/FidgetWrapper.tsx; consider extracting a shared constant to avoid drift.
Summary
This PR improves the Portfolio fidget so it can:
nounspacetom) without being overwrittenDetails
PortfolioUsernameInputto encapsulate username -> address lookupuseCurrentFid()is not availableUX behavior
Summary by CodeRabbit
New Features
Improvements