Skip to content
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

Gallery - Handle post update if uploads are completed when the editor is closed #1629

Closed
pinarol opened this issue Nov 27, 2019 · 1 comment · Fixed by wordpress-mobile/WordPress-Android#10999

Comments

@pinarol
Copy link
Contributor

pinarol commented Nov 27, 2019

We need to add a mechanism to the main apps for Gallery block that will update the post html if uploads are completed during the time block editor is closed. During the upload of a media, we use temporary IDs and local urls in the block html, but once the upload is completed, temporary IDs need to be replaced with remote IDs, similarly local urls needs to be replaced with remote urls.

We already have a similar mechanism for Image, Video, Media-Text blocks but Gallery will be more tricky because now we'll need to handle multiple upload complete events.

Android part is here inside src/main/java/org/wordpress/android/ui/posts/PostUtils.java

    public static String replaceMediaFileWithUrlInGutenbergPost(@NonNull String postContent,
                                                 String localMediaId, MediaFile mediaFile) {		                                                 String localMediaId, MediaFile mediaFile) {

iOS part is inside GutenbergImgUploadProcessor.swift and GutenbergVideoUploadProcessor.swift

Describe the solution you'd like

  1. We should avoid race conditions that can be caused by multiple uploads getting completed pretty closely.

  2. Another challenge is, the html of gallery is much more complex than single-media blocks we have so far and we'll need a smarter mechanism to find the block associated with the recently completed upload. Same is true for the replacement mechanism.

  3. The solution should not depend on the attribute order since there's no guarantee that attributes will be sorted in a certain way. We have a work in progress issue to fix this for Image, Video, Media-Text. This is sorted on iOS but in progress on Android. We don't need to wait for this issue to be fixed to start Gallery as it will need a different kind of matching mechanism anyway, but still let's keep an eye on what kind of approach is used in that issue and see if we are aligned.

  4. Also, I highly suggest making this development by using unit-tests as it is not very practical to wait for an upload to complete whenever we want to test the solution.

  5. Technical alignment between iOS and Android is another important thing.

Additional context

Since Gallery is not merged yet this PR's branch should be used for having Gallery: #1498

This is a subtask for completing Mobile gallery block - Upload options

@SergioEstevao
Copy link
Contributor

On iOS I'm planning to build up on the HTML/Block processor classes we build using regex.

More information about those can be seen in this PR: wordpress-mobile/WordPress-iOS#12925

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants