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

[Gutenberg] media upload progress reattach #9129

Merged
merged 12 commits into from
Jan 28, 2019

Conversation

mzorz
Copy link
Contributor

@mzorz mzorz commented Jan 25, 2019

Description

This PR introduces upload progress reattachment so the progress updates are reflected on the UI when you exit and enter the Editor again.

Related PRs

reattachprogress

To test:

  1. start a new draft
  2. insert an image
  3. once it starts uploading, exit the editor
  4. open the Post in the editor again
  5. observe the upload progress bar is updated correspondingly.

Note:

@marecar3 the base branch corresponds to PR #9120, which also needs to be updated with latest develop to clear the commit history difference seen here.

Update release notes:

  • If there are user facing changes, I have added an item to RELEASE-NOTES.txt.

@@ -283,7 +301,7 @@ public void setTitle(CharSequence title) {
return;
}

mWPAndroidGlueCode.setContent(title.toString(), null);
mWPAndroidGlueCode.setTitle(title.toString());
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm not sure why this change is part of this PR?

Copy link
Contributor Author

@mzorz mzorz Jan 28, 2019

Choose a reason for hiding this comment

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

I left a note in the description of the PR :D

Note:
@marecar3 the base branch corresponds to PR #9120, which also needs to be updated with latest develop to clear the commit history difference seen here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry and thanks! @mzorz

@@ -297,7 +315,7 @@ public void setContent(CharSequence text) {
}

String postContent = removeVisualEditorProgressTag(text.toString());
mWPAndroidGlueCode.setContent(null, postContent);
Copy link
Contributor

Choose a reason for hiding this comment

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

Also for this one, not sure why is changed here?

@@ -58,6 +63,9 @@

private WPAndroidGlueCode mWPAndroidGlueCode;

private ConcurrentHashMap<String, Float> mUploadingMediaProgressMax = new ConcurrentHashMap<>();
private Set<String> mFailedMediaIds = new HashSet<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to use interface Set instead of HashSet ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

new OnReattachQueryListener() {
@Override
public void onQueryCurrentProgressForUploadingMedia() {
for (String mediaId : mUploadingMediaProgressMax.keySet()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @mzorz, what about moving this into a separate method (e.g. updateMediaProgress or similar)
and also maybe we can put this mUploadingMediaProgressMax.get(mediaId) into variable (e.g. int currentProgress) before passing it to method ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed, addressed moving into a new method in 6cb4c90 - I think the intermediate local variable is unnecessary as it's only going to be used in 1 place; we can use that when it's referenced in more than 1 place so the .get() method doesn't get called on every reference. Does it make sense?

Copy link
Contributor

@marecar3 marecar3 left a comment

Choose a reason for hiding this comment

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

LGTM!

@mzorz mzorz merged commit e56e050 into gb/feature_upload_media_file Jan 28, 2019
@mzorz mzorz deleted the gb/media_upload_progress_reattach branch January 28, 2019 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants