From 0550cc570b3fcd2fbf3eebb2cab40a4c3f1f8bc5 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Fri, 15 Dec 2023 16:56:20 -0500 Subject: [PATCH 1/5] feat: Retry failed media uploads when re-establishing network connection Improve the media upload UX by automatically retrying failed uploads. --- .../org/wordpress/android/ui/posts/EditPostActivity.java | 2 +- .../wordpress/android/editor/EditorFragmentAbstract.java | 2 +- .../android/editor/gutenberg/GutenbergEditorFragment.java | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index e55af87a8882..f24b5a06d88d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -3300,7 +3300,7 @@ public void onRequestDragAndDropPermissions(DragEvent dragEvent) { } @Override - public void onMediaRetryAllClicked(Set failedMediaIds) { + public void onMediaRetryAll(Set failedMediaIds) { UploadService.cancelFinalNotification(this, mEditPostRepository.getPost()); UploadService.cancelFinalNotificationForMedia(this, mSite); ArrayList localMediaIds = new ArrayList<>(); diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/EditorFragmentAbstract.java b/libs/editor/src/main/java/org/wordpress/android/editor/EditorFragmentAbstract.java index 764f2db9394e..d9f3ff3d5bc6 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/EditorFragmentAbstract.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/EditorFragmentAbstract.java @@ -199,7 +199,7 @@ public interface EditorFragmentListener extends DialogVisibilityProvider { void onAddDeviceMediaClicked(boolean allowMultipleSelection); void onCaptureVideoClicked(); boolean onMediaRetryClicked(String mediaId); - void onMediaRetryAllClicked(Set mediaIdSet); + void onMediaRetryAll(Set mediaIdSet); void onMediaUploadCancelClicked(String mediaId); void onMediaDeleted(String mediaId); void onUndoMediaCheck(String undoedContent); diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java b/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java index bc37501dfa42..a3564cf71a55 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java @@ -926,7 +926,7 @@ private void showRetryMediaUploadDialog(final int mediaId) { new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); - mEditorFragmentListener.onMediaRetryAllClicked(mFailedMediaIds); + mEditorFragmentListener.onMediaRetryAll(mFailedMediaIds); } }); @@ -1583,5 +1583,9 @@ public void onGutenbergDialogNegativeClicked(@NonNull String instanceTag) { @Override public void onConnectionStatusChange(boolean isConnected) { getGutenbergContainerFragment().onConnectionStatusChange(isConnected); + if (hasFailedMediaUploads()) { + mEditorFragmentListener.onMediaRetryAll(mFailedMediaIds); + mFailedMediaIds.clear(); + } } } From be1c1f86e125a9380a48df74173d92f98f29314a Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Fri, 15 Dec 2023 16:59:48 -0500 Subject: [PATCH 2/5] docs: Add release note --- RELEASE-NOTES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index a645e1f85cb0..4cf4532e0989 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -3,6 +3,7 @@ 24.0 ----- * [*] Filter media types when sharing files to the editor [https://github.com/wordpress-mobile/WordPress-Android/pull/19754] +* [**] The block editor now automatically retries failed media uploads when network connectivity is re-established. [https://github.com/wordpress-mobile/WordPress-Android/pull/19803] 23.9 ----- From 47df15049648509ec3346ad10e2867c793735ead Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Sat, 16 Dec 2023 07:35:20 -0500 Subject: [PATCH 3/5] feat: Limit automatic upload retries to debug builds We will enable the feature in production once all project work is completed. --- .../android/editor/gutenberg/GutenbergEditorFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java b/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java index a3564cf71a55..9e71d7ab1723 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java @@ -1583,7 +1583,7 @@ public void onGutenbergDialogNegativeClicked(@NonNull String instanceTag) { @Override public void onConnectionStatusChange(boolean isConnected) { getGutenbergContainerFragment().onConnectionStatusChange(isConnected); - if (hasFailedMediaUploads()) { + if (BuildConfig.DEBUG && hasFailedMediaUploads()) { mEditorFragmentListener.onMediaRetryAll(mFailedMediaIds); mFailedMediaIds.clear(); } From c114528b47a56b3f9394acdf771b5c393a3447fb Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Sat, 16 Dec 2023 07:37:35 -0500 Subject: [PATCH 4/5] refactor: Remove unnecessary clearing of failed media IDs This was originally added in an attempt to clear an unexpected "failed media upload" notification displayed after closing the editor. However, it did not resolve that issue, it must originate from some other location. Additionally, it would appears successful media uploads already manage removing media IDs from the `mFailedMediaIds` collection. --- .../android/editor/gutenberg/GutenbergEditorFragment.java | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java b/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java index 9e71d7ab1723..693dfd49e775 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java @@ -1585,7 +1585,6 @@ public void onConnectionStatusChange(boolean isConnected) { getGutenbergContainerFragment().onConnectionStatusChange(isConnected); if (BuildConfig.DEBUG && hasFailedMediaUploads()) { mEditorFragmentListener.onMediaRetryAll(mFailedMediaIds); - mFailedMediaIds.clear(); } } } From 3fb85a3440f7ba063997307eb811c44d93e3aef8 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Tue, 19 Dec 2023 10:49:17 -0500 Subject: [PATCH 5/5] feat: Only retry media uploads if a network connection is available Retrying media uploads without a network connection will undoubtedly fail again. Co-authored-by: Antonis Lilis --- .../android/editor/gutenberg/GutenbergEditorFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java b/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java index 693dfd49e775..16e2f76c9fcc 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java @@ -1583,7 +1583,7 @@ public void onGutenbergDialogNegativeClicked(@NonNull String instanceTag) { @Override public void onConnectionStatusChange(boolean isConnected) { getGutenbergContainerFragment().onConnectionStatusChange(isConnected); - if (BuildConfig.DEBUG && hasFailedMediaUploads()) { + if (BuildConfig.DEBUG && isConnected && hasFailedMediaUploads()) { mEditorFragmentListener.onMediaRetryAll(mFailedMediaIds); } }