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

GB finish uploads out of editor #10954

Merged
merged 9 commits into from
Feb 7, 2019

Conversation

SergioEstevao
Copy link
Contributor

Fixes wordpress-mobile/gutenberg-mobile#206

This PR adds the possibility to async publish Post on GB while images are uploading.

To test:

  • Start a new post using GB
  • Add an image from the device to it
  • While the upload is going on press Publish
  • See the upload finish and the post published on the post list
  • Go back to the post and see if all content is ok
  • Do the same as above but this simulate an error while the upload is going on (go offline)
  • Open the post
  • And see if the image is on error state.

@SergioEstevao SergioEstevao added the Gutenberg Editing and display of Gutenberg blocks. label Feb 6, 2019
@SergioEstevao SergioEstevao added this to the 11.8 milestone Feb 6, 2019
if media.remoteStatus == .failed {
return
}
if media.mediaType == .image {
let imgPostUploadProcessor = ImgUploadProcessor(mediaUploadID: mediaUploadID, remoteURLString: remoteURLStr, width: media.width?.intValue, height: media.height?.intValue)
postContent = imgPostUploadProcessor.process(postContent)
let gutenbergImgPostUploadProcessor = GutenbergImgUploadProcessor(mediaUploadID: gutenbergMediaUploadID, serverMediaID: mediaID, remoteURLString: remoteURLStr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this replacing the post content for all posts, not just those in Gutenberg?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we apply both processors on all posts, but only the GB ones will be affected for the processor, because they have a different format for the media uploads ids.

Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @SergioEstevao ! This is working great 🎉

There is one small detail:
When I open gutenberg with an upload running, there is a warning saying
Sending 'mediaUpload' with no listeners registered
img_1022

That happens when we try to send messages to RN too early, and the JS is not loaded yet.
There is a isJSLoaded property in Gutenberg.swift that we can use in these cases, and avoid sending messages before the bridge is ready.

Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @SergioEstevao for the fixes, it's working great! 🎉

@SergioEstevao SergioEstevao merged commit 21c74cf into develop Feb 7, 2019
@SergioEstevao SergioEstevao deleted the issue/gb_finish_uploads_out_of_editor branch February 7, 2019 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gutenberg Editing and display of Gutenberg blocks.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants