-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[Mobile] MediaUploadProgress - Cancel failed or in progress uploads if the media block is removed #61251
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 |
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.
Testing worked on both platforms (I was more thorough on iOS, but we can also hit Android tests in the release). Code makes sense to me as well. Thanks @geriux! 🚀
…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
MediaUploadProgress
component 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
requestImageUploadCancel
in the bridge for both iOS and Android that cancels an upload from a media ID.A new function was added to set the
mediaUrl
used for the thumbnail without having to pass the progress state, to prevent messing with the progress bar while the upload is happening.Changes for
mediaUploadUpdate
andmediaUpdate
were needed for the iOS bridge functions to setprogress
,state
, andserverID
as optional params. See the iOS change for this use case.Media&Text
andCover
blocks 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 Booster
I'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