Conversation
…e optional params for state and progress. Needed to be able to update the thumbnails only.
…soon as it is available
…dated thumbnail for images
…on as it is ready
… if there's a pending or failed upload. It also updates the code to be able to update the media thumbnail when there's no state update passed as a param.
|
Size Change: 0 B Total Size: 1.75 MB ℹ️ View Unchanged
|
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @dangermattic, @mzorz. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Tests - iOSGallery - 1
Gallery - 2
MediaText - 1
MediaText - 2
MultipleUpload - 1
Image - 1
Cover - 1
cover_block.mp4 |
Tests - AndroidGallery - 1
Gallery - 2
MediaText - 1
MediaText - 2
MultipleUpload - 1
Image - 1
Cover - 1 |
…f the media block is removed (WordPress#61251) * React Native Bridge - Update mediaUploadUpdate and mediaUpdate to have optional params for state and progress. Needed to be able to update the thumbnails only. * Media & Text - Update updateMediaProgress to update the thumbnail as soon as it is available * Media & Text - Pass new callback onMediaThumbnailUpdate to set the updated thumbnail for images * Cover block - Update onUpdateMediaProgress to set the thumbnail as soon as it is ready * Media Upload Progress - Request cancelling an image upload on unmount if there's a pending or failed upload. It also updates the code to be able to update the media thumbnail when there's no state update passed as a param. * Adds requestImageUploadCancel mock
Fixes wordpress-mobile/WordPress-iOS#23124
Fixes wordpress-mobile/gutenberg-mobile#1595
Related PRs:
What?
Currently, when an image block (Image, Media&Text, Cover) is removed with an ongoing or failed upload, the media upload is not canceled.
Why?
The media upload is expected to be canceled if the block is removed and the upload hasn't finished or if it failed to upload for any reason.
How?
Since the
MediaUploadProgresscomponent handles the upload states, I added the logic to cancel the upload when the component is removed and there's an ongoing/failed upload.There was already a method
requestImageUploadCancelin the bridge for both iOS and Android that cancels an upload from a media ID.A new function was added to set the
mediaUrlused for the thumbnail without having to pass the progress state, to prevent messing with the progress bar while the upload is happening.Changes for
mediaUploadUpdateandmediaUpdatewere needed for the iOS bridge functions to setprogress,state, andserverIDas optional params. See the iOS change for this use case.Media&TextandCoverblocks were updated to show the thumbnail right away with these changes. The Image block was already updated to expect these updates.Testing Instructions
Note
Please use the following test builds to test these changes:
Removing an Image block with an ongoing/failed upload
Tip
For iOS I suggest using the Network Link Conditioner tool in the Developer settings
For Android there are apps like
Network Speed BoosterI'd suggest going through all of the media upload tests or at least some of them:
Gallery - 1
Gallery - 2
MediaText - 1
MediaText - 2
MultipleUpload - 1
Image - 1
Cover - 1
Testing Instructions for Keyboard
N/A
Screenshots or screencast
RemoveUpload.mov