User profile (migration 6/8) - #694
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
| useEffect(() => { | ||
| let ignore = false; | ||
| setErrorMessage(''); | ||
|
|
||
| fetchUser(userID) | ||
| .then((nextUser) => { | ||
| if (!ignore) { | ||
| setUser(nextUser); | ||
| } | ||
| }) | ||
| .catch(() => { | ||
| if (!ignore) { | ||
| setErrorMessage(`Could not load user ${userID}.`); | ||
| } | ||
| }); | ||
|
|
||
| return () => { | ||
| ignore = true; | ||
| }; | ||
| }, [userID]); |
There was a problem hiding this comment.
📝 Info: Stale profile persists across navigation
On userID change the effect resets errorMessage but never clears user, so navigating from a loaded profile to one that errors keeps the previous profile on screen. This mirrors ItemDetails and the Angular original.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Intentional — as you note, it matches the Angular original (which also only assigned user on success) and the sibling ItemDetails. Changing it would be a behavior change rather than a port, so I'm leaving it consistent across the three views; worth a follow-up if the stale-view-on-error transition is considered a bug in its own right.
6af712a to
fb9e1aa
Compare
Co-Authored-By: Charity Quinn <charity.quinn@cognition.ai>
Co-Authored-By: Charity Quinn <charity.quinn@cognition.ai>
Co-Authored-By: Charity Quinn <charity.quinn@cognition.ai>
fb9e1aa to
1754abb
Compare
Summary
Stacked on #693. Ports
user/user.componenttosrc-react/user/User.tsxand adds/user/:id, completing the route surface — the author links added in PR5 now resolve.fetchUser(id)in an effect keyed on the route param, sameignorestaleness guard; error message is byte-identical (Could not load user <id>.).navigate(-1)),main-detailswith id / karma★/Created {created}, and theother-detailsblock only whenaboutis present. ThataboutHTML goes through PR5'ssanitizeHtml()wrapper — it's profile-owner-authored, and Angular's[innerHTML]sanitized it, so rendering it raw would have been a regression rather than parity. The Angular user view has nomain-contentwrapper, so neither does this one.user.component.scssis copied unchanged except its:host >>> prerule, rescoped to.other-details prefor the same reason as PR5's comment styles.Verified:
yarn react:buildpasses; the error path renders the message rather than a blank page.Two things left as-is, both matching the original: a failed load after a successful one keeps the previous profile on screen (Angular only assigned
useron success, andItemDetailsbehaves the same way), and a non-numeric route param is passed through to the API.One gap worth flagging: the upstream API's
/user/<id>endpoint currently 404s for every id tried (pg,dang, real story authors), so the populated profile — karma, created,about— could not be verified against live data. That's a node-hnapi outage, not a code issue; the loading/error paths and markup are verified, the happy path is not.Devin-Org: engineering
Link to Devin session: https://app.devin.ai/sessions/1ff25c6cf2f949458f82cc596fc79c65
Requested by: @charityquinn-cognition