web-stories-wp icon indicating copy to clipboard operation
web-stories-wp copied to clipboard

Media: Processing items missing after opening media dialog

Open spacedmonkey opened this issue 3 years ago • 3 comments

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

  1. Open editor.
  2. Upload a video.
  3. Open media dialog.
  4. Close media dialog.
  5. 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:

spacedmonkey avatar Dec 10 '21 19:12 spacedmonkey

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.

swissspidy avatar Jun 24 '22 19:06 swissspidy

This is also an issue, when change a filters as well or open media picker.

spacedmonkey avatar Jun 24 '22 21:06 spacedmonkey

Both scenarios result in the FETCH_MEDIA_SUCCESS reducer being called

swissspidy avatar Jul 13 '22 12:07 swissspidy