-
Notifications
You must be signed in to change notification settings - Fork 30
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
Classifier: refactor UPP data-fetching with hooks #2988
Conversation
c439429
to
b654d32
Compare
6fac5b9
to
bb9fbd8
Compare
cfa5390
to
ccd713f
Compare
f1ebe87
to
f455f24
Compare
ccd713f
to
261e5d6
Compare
261e5d6
to
94aa439
Compare
94aa439
to
9d9cb4a
Compare
3ba1f61
to
d4e02b2
Compare
f222424
to
8b7b3c2
Compare
d3f80e6
to
df9764d
Compare
23cdc0e
to
a685f50
Compare
cc18a5a
to
653c6e4
Compare
3217b18
to
18cb2f1
Compare
5b1bda3
to
8457714
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, tested on Planet Findes BETA with two different staging users and signed out, tutorials loaded or didn't load as expected.
Not for this PR, and more for my understanding than review notes, but I notice the hooks don't have try/catch blocks for .get/.post requests, not sure if that's because not needed or something to consider for future refactor.
|
||
import { usePanoptesAuth } from './' | ||
|
||
const SWRoptions = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 consistent with other hooks using SWR, LGTM
} | ||
function clear() { | ||
self.resources.clear() | ||
self.loadingState = asyncStates.success |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ loadingState
is defined in the ResourceStore
model
Remove data-fetching from the classifier's UPP store and move it into a `useProjectPreferences` hook instead. Preferences should be fetched when the logged-in user changes. UPP updates are still handled by the store, so the store is updated whenever fresh preferences are received from Panoptes.
8457714
to
54c78a1
Compare
One of the advantages of using the const { data, error } = useSWR(key, fetcher, options) |
Remove data-fetching from the classifier's UPP store and move it into a
useProjectPreferences
hook instead. Preferences should be fetched when the logged-in user changes. UPP updates are still handled by the store, so the store is updated whenever fresh preferences are received from Panoptes.This PR builds on the user hooks in #2940, so that should be reviewed first. Following recent bugs, caused by problems with tracking user logged-in status via the UPP store, this shifts user data-fetching from our own home-grown code to SWR, which will refresh preferences in the background while the classifier is in use.
TODO:
Package:
lib-classifier
Review Checklist
General
Components
Apps
yarn panic && yarn bootstrap
ordocker-compose up --build
and app works as expected?Publishing
Post-merging