-
Notifications
You must be signed in to change notification settings - Fork 2
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
NickAkhmetov / HMP-235 Add support for text-only publication vignettes #3159
NickAkhmetov / HMP-235 Add support for text-only publication vignettes #3159
Conversation
Co-authored-by: L Choy <[email protected]>
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.
Thanks! I'm curious if this would handle undefined figures in a vignette.
context/app/static/js/components/publications/PublicationVignette/hooks.ts
Outdated
Show resolved
Hide resolved
context/app/static/js/components/publications/PublicationVignette/hooks.ts
Outdated
Show resolved
Hide resolved
- Account for potentially undefined/null vignettes (no guarantee that it'll be an empty list) - Move multiFetcher to shared utils folder
const urls = | ||
vignette.figures?.map( | ||
({ file }) => `${assetsEndpoint}/${uuid}/vignettes/${vignetteDirName}/${file}?token=${groupsToken}`, | ||
) ?? []; | ||
const { data } = useSWR(urls, multiFetcher, { | ||
revalidateOnFocus: false, | ||
revalidateOnReconnect: false, | ||
}); |
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.
What happens when figures is undefined and in turn urls are undefined?
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.
The nullish coalescing fallback on line 19 ensures that urls
is always at least an empty list; even if that wasn't there, swr's conditional fetching functionality would ensure that the fetch doesn't run, data
remains undefined, and the return undefined
case on line 42 would be reached. https://swr.vercel.app/docs/conditional-fetching
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.
Ah sorry didn't catch that!
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.
Actually, on second thought, that ?? []
shouldn't be there since an empty array is truthy. One moment.
This PR adjusts the Vitessce vignette rendering and fetching logic:
js/*
paths are properly recognized in TS filesI've tested this locally; if there are no conf files provided, the accordion only displays the markdown description.
The markdown description is also instantly visible as the accordion expands/Vitessce loads, instead of popping in at the same time Vitessce finishes loading. You can see it flash by in the recorded demo:
2023-07-10.hmp-235.demo.mov
Future Improvements
I ran into some problems with Storybook failing to parse
Contexts.tsx
after I tried to convert that file; I'll revisit it at another time (created HMP-250), and have worked around it by defining the types in JS comments.