Skip to content
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

Merged

Conversation

NickAkhmetov
Copy link
Collaborator

This PR adjusts the Vitessce vignette rendering and fetching logic:

  • The lack of a vitessce conf no longer blocks the rendering of the vignette description, which allows text-only vignettes to be displayed correctly
  • Vitessce conf fetching has been updated
  • I've started to gradually include more TypeScript annotations where appropriate
  • Improved tsconfig so that js/* paths are properly recognized in TS files

I'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.

CHANGELOG-hmp-235.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@john-conroy john-conroy left a 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.

- Account for potentially undefined/null vignettes (no guarantee that it'll be an empty list)
- Move multiFetcher to shared utils folder
Comment on lines 16 to 23
const urls =
vignette.figures?.map(
({ file }) => `${assetsEndpoint}/${uuid}/vignettes/${vignetteDirName}/${file}?token=${groupsToken}`,
) ?? [];
const { data } = useSWR(urls, multiFetcher, {
revalidateOnFocus: false,
revalidateOnReconnect: false,
});
Copy link
Collaborator

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?

Copy link
Collaborator Author

@NickAkhmetov NickAkhmetov Jul 12, 2023

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

Copy link
Collaborator

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!

Copy link
Collaborator Author

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.

john-conroy
john-conroy previously approved these changes Jul 12, 2023
@NickAkhmetov NickAkhmetov merged commit ca6964b into main Jul 12, 2023
8 checks passed
@NickAkhmetov NickAkhmetov deleted the nickakhmetov/hmp-235-enable-display-of-text-only-vignettes branch July 12, 2023 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants