hypothesis / hypothesis/client
Sidebar app may fetch annotations twice on launch
- Dominant language
- Mustache
- Stars
- 730
- Forks
- 224
- PR merge metrics
- No merged PRs in 30d
Description
Initially reported in https://github.com/hypothesis/client/pull/3163#issuecomment-800255001, the client can end up fetching annotations twice when it starts if the user is initially logged in.
This happens because the code that triggers the annotation fetch is a [`useEffect` effect](https://github.com/hypothesis/client/blob/0727d13b6ec56e3cf1f5ae6b060cbd8ba822ecc0/src/sidebar/components/SidebarView.js#L109) in `SidebarView` that has a dependency upon the current profile's `userid`. On startup when the user is logged in this value starts out as `null` (the value of the default/dummy profile struct defined in `store/modules/session.js`) and then transitions to the actual user ID after the profile is fetched.
Logically what we actually want to do is fetch annotations upon startup and then only after an explicit login/logout action, not when the `userid` changes because the client has simply fetched it.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.