-
Notifications
You must be signed in to change notification settings - Fork 63
Await fetching related media in the single result store #1349
Conversation
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.
I was wondering why the call to useRelatedMediaStore().fetchMedia()
can't be async so inspecting Pinia in the single results page I found that the single-result
store does not persist or it is not initialized, it's not shown in the list on Vue Devtools.
So making the call from the setup
function instead of the single-result
store seems to allow it to work asynchronously.
269d3b3
to
b908dc6
Compare
Thank you for catching this, @krysal ! |
# Conflicts: # src/locales/po-files/openverse.pot
Storybook and Tailwind configuration previews: Ready Storybook: https://wordpress.github.io/openverse-frontend/1349 Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again. You can check the GitHub pages deployment action list to see the current status of the deployments. |
Size Change: +44 B (0%) Total Size: 1.43 MB
ℹ️ View Unchanged
|
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! 🎉
Yes, that's my suspicion, that the Pinia instance from the |
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.
💯+ for more conversion to Composition API. It would be nice to add some tests but this effectively fixes the problem ☑️
* If the result is available in the media store (from search results or related media), | ||
* we can re-use it. Otherwise, we fetch it from the API. | ||
* The media objects from the search results currently don't have filetype or filesize properties. |
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.
Why reuse it? 🤔 I'm not sure if we gain much from this optimization as the search endpoint doesn't return all the fields we need in the single result page.
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.
I didn't know that the search endpoint doesn't return all the fields when I implemented this. I think there are only filetype
and filesize
fields that are not returned currently. I think re-using still improves the performance of single result loading.
This fixes #1377 😁 |
The state data from the server is saved to Let's see how it goes now, and, if necessary, we can refactor later. |
Fixes
Fixes #1339 by @AetherUnbound
Description
This PR adds
await
to ensure that related media are fetched on SSR as well as on CSR.The related fetch call is moved after the main single result is fetched successfully.
Testing Instructions
Try loading a single result page on SSR, or opening a single result page and refreshing. The related media should be there.
Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin