web-stories-wp
web-stories-wp copied to clipboard
Media: Processing items missing after opening media dialog
Bug Description
While a uploading a media asset, if you open the media dialog and close it, the uploading item disappears.
Expected Behaviour
Steps to Reproduce
- Open editor.
- Upload a video.
- Open media dialog.
- Close media dialog.
- See media is missing.
Screenshots
https://user-images.githubusercontent.com/237508/145632298-5237e4cf-696e-47a5-9695-45515470ae42.mov
Additional Context
- Plugin Version:
- WordPress Version:
- Operating System:
- Browser:
Relevant code:
When closing the media dialog we call resetWithFetch:
https://github.com/GoogleForCreators/web-stories-wp/blob/5fd62c1d15b183880b96d35f9de6f1975487847d/packages/story-editor/src/components/form/mediaUploadButton.js#L164
resetWithFetch calls fetchMedia with the fetchMediaSuccess callback on success:
https://github.com/GoogleForCreators/web-stories-wp/blob/5fd62c1d15b183880b96d35f9de6f1975487847d/packages/story-editor/src/app/media/local/useContextValueProvider.js#L185-L188
The FETCH_MEDIA_SUCCESS reducer replaces the list of media items in state with the newly fetched list:
https://github.com/GoogleForCreators/web-stories-wp/blob/5fd62c1d15b183880b96d35f9de6f1975487847d/packages/story-editor/src/app/media/pagination/reducer.js#L51-L65
This is where we'd need to check the existing items to see if they are in progress and prepend them to the beginning of the new list again. But that might me the tricky part.
This is also an issue, when change a filters as well or open media picker.
Both scenarios result in the FETCH_MEDIA_SUCCESS reducer being called