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

Async notifications: Post error / success notifications (part II): #6763

Conversation

mzorz
Copy link
Contributor

@mzorz mzorz commented Oct 20, 2017

Continues #6756 (this one should be merged into that other one first!)
Also adds the functionality requested for in #6407 (adding the button to the Posts list should come in another PR)

This one implements Post error notifications (and snackbars) on top of the Post success notifications work done in #6756

screen shot 2017-10-18 at 10 23 36 am

Notes:

  • snackbars have been enhanced
  • the duration for these is 5 seconds now in this PR
  • we implemented the RETRY functionality for Aztec only (i.e. if you're using the Visual editor, then a failed upload won't make the RETRY button appear in your error notification)
  • as in Post sucess notifications (part 1) #6756 , didn't implement the CLOSE button (see my comment there)
  • changing the color for the quick actions only didn't seem to work for me right away, (i.e. the accent color is changed as well for the notification icon as can be seen here below)
  • in the notification, we are adding the granular reason in the BigStyle text so the user knows why something happened (for example, "Lost connection to the server" or whatever other reason we already know about and were informing in the current release version)

screen shot 2017-10-20 at 5 28 38 pm

  • also, note we are keeping the title as it was, as we're using the Post title if one post has failed

To test:

CASE A:

  1. start a new draft
  2. include a media item (try to make it a large enough one so to be able to continue uploading while exiting the editor)
  3. exit the editor
  4. turn airplane mode ON
  5. observe the error notification appears and reads “1 post, 1 files not uploaded - RETRY”

CASE B:

  1. start a new draft
  2. include 1 media item (try to make it a large enough one so to be able to continue uploading while exiting the editor)
  3. while the media item above approaches half of it being uploaded, include a new media item there
  4. exit the editor
  5. check the notification until it changes from “1/2 media items” to “2/2 media items” (wording of these is changed in another PR Upload foreground notification wording #6748)
  6. turn airplane mode ON
  7. observe the error notification appears, and reads “1 post, 1 files not uploaded (1 file successfully uploaded) - RETRY”

CASE C: AFTER THIS LAST CASE ABOVE:
8. turn airplane mode OFF
9. tap on the notification’s RERTY quick action
10. verify the post and media items are re-uploaded and finish successfully

CASE D:

  1. repeat CASE B.
  2. now turn airplane mode OFF
  3. before attempting a retry, please delete one of the media items that FAILED (the second one you added to the Post) from the Post (enter the editor, place the cursor to the right of the picture, then hit backspace to delete), and exit the editor.
  4. now, tap on the notification’s RETRY quick action
  5. You should see the app retries to upload the remaining media item within the Post and updates the Post gracefully as well.

cc @nbradbury

mzorz referenced this pull request Oct 22, 2017
… added PUBLISH quick action for uploaded drafts
@mzorz mzorz changed the base branch from mzorz/post-success-notifications to issue/6389-upload-service-notification October 24, 2017 01:01
@mzorz
Copy link
Contributor Author

mzorz commented Oct 24, 2017

This PR is now ready for review @nbradbury - please note Media-only success and error (i.e. final) notification and Retry implementation is to be addressed on a separate PR 🙇

@nbradbury nbradbury self-assigned this Oct 24, 2017
public void onEventMainThread(UploadService.UploadErrorEvent event) {
SiteModel site = getSelectedSite();
if (site != null) {
if (event.post.getLocalSiteId() == site.getId()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to null check event.post here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

uh, nice! addressed in 0ad299b

@@ -515,7 +530,8 @@ public void onPostUploaded(PostStore.OnPostUploaded event) {
if (site != null) {
if (event.post.getLocalSiteId() == site.getId()) {
UploadUtils.onPostUploadedSnackbarHandler(getActivity(),
getActivity().findViewById(R.id.coordinator), event, site, mDispatcher);
getActivity().findViewById(R.id.coordinator),
Copy link
Contributor

Choose a reason for hiding this comment

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

We can drop final PostModel post = event.post; at the top of this 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.

addressed in fcfa5c2

@@ -326,4 +326,9 @@ static boolean updatePostContentIfDifferent(PostModel post, String newContent) {
}
return false;
}

public static boolean isFirstTimePublish(PostModel post) {
return PostStatus.fromPost(post) == PostStatus.DRAFT
Copy link
Contributor

Choose a reason for hiding this comment

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

EditPostActivity has a similar method here whose logic is different than this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's correct - EditPostActivity can determine things differently given it holds an mOriginalPost and can eventually tell if there are any differences. It is different for the UploadService or, fwiw, anywhere else other than the Editor where changes might happen anytime.

}

void incrementUploadedPostCountFromForegroundNotification(@NonNull PostModel post) {
void incrementUploadedPostCountFromForegroundNotificationOrFinish(@NonNull PostModel post) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused by orFinish being part of this method name. Any chance we can get rid of it, especially since the method name is so long?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing! got it back in 6aa5620 and also renamed the Media method counterpart to keep it the same way

@nbradbury
Copy link
Contributor

This is likely unrelated to this PR, but the post list was (correctly) showing that a post's media failed to upload yet the upload progress remained visible.

screenshot_1508855621

@nbradbury
Copy link
Contributor

I ran into a situation where I received an "Upload failed" notification yet the "Uploading" notification didn't go away.

screenshot_1508855587

@nbradbury
Copy link
Contributor

I'm guessing GENERIC_ERROR is coming from the backend? If so, we should detect that error message and not display it to the user.

screenshot_1508859632

@mzorz
Copy link
Contributor Author

mzorz commented Oct 24, 2017

but the post list was (correctly) showing that a post's media failed to upload yet the upload progress remained visible.

Nice catch Nick! , addressed in a different PR #6782

@mzorz
Copy link
Contributor Author

mzorz commented Oct 24, 2017

I'm guessing GENERIC_ERROR is coming from the backend? If so, we should detect that error message and not display it to the user.

It's defined in the network layer (a.k.a FluxC) - we've seen that before, and IIRC we decided to let it all the way up to the user to make it easier for us to understand what's going on when people reaching out to us through Helpshift. That said, we can come up with something nicer that still is "unique", but I'd need some way to reproduce. Do you remember what you did to make it fail this way?

@mzorz
Copy link
Contributor Author

mzorz commented Oct 24, 2017

I ran into a situation where I received an "Upload failed" notification yet the "Uploading" notification didn't go away.

#6763 (comment)
addressed in b2b49d6

@nbradbury
Copy link
Contributor

Do you remember what you did to make it fail this way?

I simply enabled airplane mode during upload, but other times I did that I received a different error.

@nbradbury
Copy link
Contributor

:shipit:

@nbradbury nbradbury merged commit 02bd896 into issue/6389-upload-service-notification Oct 25, 2017
@mzorz mzorz deleted the mzorz/post-error-success-notifications branch November 6, 2017 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants