From c3cad46b6396998831567b39e4a920eba3839a00 Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Tue, 26 Mar 2024 17:03:09 +0200 Subject: [PATCH 01/28] Updates: fluxC version for development --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 444af04671b5..80c229d4c634 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ ext { automatticTracksVersion = '3.5.0' gutenbergMobileVersion = 'v1.116.0-alpha2' wordPressAztecVersion = 'v2.1.1' - wordPressFluxCVersion = '2.72.0' + wordPressFluxCVersion = '2982-70e163307b6b6f0c4c4d3499c38cd5e66ae56a0e' wordPressLoginVersion = '1.14.1' wordPressPersistentEditTextVersion = '1.0.2' wordPressUtilsVersion = '3.14.0' From 7df3642091571ccd04a38daab8a0bb968a83f052 Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Wed, 27 Mar 2024 13:34:17 +0200 Subject: [PATCH 02/28] Add logs --- .../android/ui/main/WPMainActivity.java | 3 ++ .../android/ui/mysite/MySiteViewModel.kt | 3 ++ .../android/ui/posts/EditPostActivity.java | 5 ++++ .../android/ui/posts/PostListEventListener.kt | 10 +++++++ .../ui/posts/editor/StorePostViewModel.kt | 5 ++++ .../ui/reader/ReaderPostListActivity.java | 3 ++ .../ui/reader/ReaderPostPagerActivity.java | 3 ++ .../android/ui/uploads/PostUploadHandler.java | 29 ++++++++++++------- .../android/ui/uploads/UploadService.java | 4 +++ .../viewmodel/pages/ActionPerformer.kt | 5 ++++ .../viewmodel/pages/PageListEventListener.kt | 3 ++ .../android/viewmodel/posts/PostFetcher.kt | 2 ++ 12 files changed, 65 insertions(+), 10 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java index 25afd022eb4a..63603e8ad290 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java @@ -10,6 +10,7 @@ import android.os.Handler; import android.os.Looper; import android.text.TextUtils; +import android.util.Log; import android.view.HapticFeedbackConstants; import android.view.View; import android.view.ViewGroup; @@ -1736,6 +1737,8 @@ private void initSelectedSite() { @SuppressWarnings("unused") @Subscribe(threadMode = ThreadMode.MAIN) public void onPostUploaded(OnPostUploaded event) { + Log.d("myTest", "WPMainActivity§.onPostUploaded()"); + // WPMainActivity never stops listening for the Dispatcher events and as a result it tries to show the // SnackBar even when another activity is in the foreground. However, this has a tricky side effect, as if // the Activity in the foreground is showing a Snackbar the SnackBar is dismissed as soon as the diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt index 6dcea39fc7a2..d533b6eaea42 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt @@ -3,6 +3,7 @@ package org.wordpress.android.ui.mysite import android.net.Uri +import android.util.Log import androidx.annotation.StringRes import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData @@ -421,6 +422,8 @@ class MySiteViewModel @Inject constructor( // FluxC events @Subscribe(threadMode = MAIN) fun onPostUploaded(event: OnPostUploaded) { + Log.d("myTest","MySiteViewModel.onPostUploaded()") + if (!event.isError) { event.post?.let { if (event.post.answeredPromptId > 0 && event.isFirstTimePublish) { 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 a3b23f033a2a..3d0725b4cb66 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 @@ -10,6 +10,7 @@ import android.os.Handler; import android.os.Looper; import android.text.TextUtils; +import android.util.Log; import android.view.DragEvent; import android.view.Menu; import android.view.MenuInflater; @@ -3672,6 +3673,8 @@ public void onMediaListFetched(OnMediaListFetched event) { @SuppressWarnings("unused") @Subscribe(threadMode = ThreadMode.MAIN) public void onPostChanged(OnPostChanged event) { + Log.d("myTest", "EditPostActivity.onPostChanged()"); + if (event.causeOfChange instanceof CauseOfOnPostChanged.UpdatePost) { if (!event.isError()) { // here update the menu if it's not a draft anymore @@ -3745,6 +3748,8 @@ private void handleRemotePreviewUploadResult(boolean isError, RemotePreviewLogic @SuppressWarnings("unused") @Subscribe(threadMode = ThreadMode.MAIN) public void onPostUploaded(OnPostUploaded event) { + Log.d("myTest", "EditPostActivity.onPostUploaded()"); + final PostModel post = event.post; if (post != null && post.getId() == mEditPostRepository.getId()) { if (!isRemotePreviewingFromEditor()) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt index f0b1f2029a11..8806c1fec179 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt @@ -1,5 +1,6 @@ package org.wordpress.android.ui.posts +import android.util.Log import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner @@ -104,6 +105,8 @@ class PostListEventListener( @Suppress("unused", "LongMethod", "ComplexMethod") @Subscribe(threadMode = MAIN, priority = 5) fun onPostChanged(event: OnPostChanged) { + Log.d("myTest","PostListEventListener.onPostChanged()") + // We need to subscribe on the MAIN thread, in order to ensure the priority parameter is taken into account. // However, we want to perform the body of the method on a background thread. launch { @@ -183,6 +186,13 @@ class PostListEventListener( @Suppress("unused") @Subscribe(threadMode = BACKGROUND) fun onPostUploaded(event: OnPostUploaded) { + Log.d("myTest","PostListEventListener.onPostUploaded(), error = ${event.error.message}") + + if (event.isError && event.error.type == PostStore.PostErrorType.OLD_REVISION) { + Log.d("","") + return + } + if (event.post != null && event.post.localSiteId == site.id) { if (!isRemotePreviewingFromPostsList.invoke() && !isRemotePreviewingFromEditor(event.post)) { triggerPostUploadAction.invoke( diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/StorePostViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/StorePostViewModel.kt index 684285199203..694dc146c9f4 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/StorePostViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/StorePostViewModel.kt @@ -1,6 +1,7 @@ package org.wordpress.android.ui.posts.editor import android.content.Context +import android.util.Log import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import kotlinx.coroutines.CoroutineDispatcher @@ -219,12 +220,16 @@ class StorePostViewModel @Suppress("unused", "UNUSED_PARAMETER") @Subscribe fun onPostUploaded(event: OnPostUploaded) { + Log.d("myTest","StorePostViewModel.onPostUploaded(), error = ${event.error.message}") + hideSavingProgressDialog() } @Suppress("unused", "UNUSED_PARAMETER") @Subscribe fun onPostChanged(event: OnPostChanged) { + Log.d("myTest","StorePostViewModel.onPostChanged()") + hideSavingProgressDialog() // Refresh post content if needed diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java index 0dae81b0e252..872c9f3397c0 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java @@ -5,6 +5,7 @@ import android.content.ActivityNotFoundException; import android.content.Intent; import android.os.Bundle; +import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -356,6 +357,8 @@ public void onClick(View v) { @SuppressWarnings("unused") @Subscribe(threadMode = ThreadMode.MAIN) public void onPostUploaded(OnPostUploaded event) { + Log.d("myTest", "ReaderPostListActivity.onPostUploaded()"); + SiteModel site = mSiteStore.getSiteByLocalId(mSelectedSiteRepository.getSelectedSiteLocalId()); if (site != null && event.post != null) { mUploadUtilsWrapper.onPostUploadedSnackbarHandler( diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java index 9f7f2de1c01c..ea639ecc2282 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java @@ -7,6 +7,7 @@ import android.os.Bundle; import android.os.Parcelable; import android.text.TextUtils; +import android.util.Log; import android.util.SparseArray; import android.view.MenuItem; import android.view.View; @@ -1115,6 +1116,8 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { @SuppressWarnings("unused") @Subscribe(threadMode = ThreadMode.MAIN) public void onPostUploaded(OnPostUploaded event) { + Log.d("myTest", "ReaderPostPagerActivity.onPostUploaded()"); + SiteModel site = mSiteStore.getSiteByLocalId(mSelectedSiteRepository.getSelectedSiteLocalId()); if (site != null && event.post != null) { mUploadUtilsWrapper.onPostUploadedSnackbarHandler( diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java index 16b347394a4e..5f6446b5b75f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java @@ -8,6 +8,7 @@ import android.provider.MediaStore.Images; import android.provider.MediaStore.Video; import android.text.TextUtils; +import android.util.Log; import android.util.SparseArray; import androidx.annotation.NonNull; @@ -650,6 +651,9 @@ public void handleAutoSavePostIfNotDraftResult(@NonNull AutoSavePostIfNotDraftRe @SuppressWarnings("unused") @Subscribe(threadMode = ThreadMode.MAIN, priority = 9) public void onPostUploaded(OnPostUploaded event) { + Log.d("myTest", "PostUploadHandler.onPostUploaded(), error = " + event.error.message); + + // check if the event is related to the PostModel that is being uploaded by PostUploadHandler if (!isPostUploading(event.post)) { return; @@ -659,16 +663,21 @@ public void onPostUploaded(OnPostUploaded event) { if (event.isError()) { AppLog.w(T.POSTS, "PostUploadHandler > Post upload failed. " + event.error.type + ": " + event.error.message); - Context context = WordPress.getContext(); - String errorMessage = mUiHelpers.getTextOfUiString(context, - UploadUtils.getErrorMessageResIdFromPostError(PostStatus.fromPost(event.post), event.post.isPage(), - event.error, mUploadActionUseCase.isEligibleForAutoUpload(site, event.post))).toString(); - String notificationMessage = UploadUtils.getErrorMessage(context, event.post.isPage(), errorMessage, false); - mPostUploadNotifier.removePostInfoFromForegroundNotification(event.post, - mMediaStore.getMediaForPost(event.post)); - mPostUploadNotifier.incrementUploadedPostCountFromForegroundNotification(event.post); - mPostUploadNotifier.updateNotificationErrorForPost(event.post, site, notificationMessage, 0); - sFirstPublishPosts.remove(event.post.getId()); + + if (event.error.type == PostStore.PostErrorType.OLD_REVISION) { + Log.d("",""); + } else { + Context context = WordPress.getContext(); + String errorMessage = mUiHelpers.getTextOfUiString(context, + UploadUtils.getErrorMessageResIdFromPostError(PostStatus.fromPost(event.post), event.post.isPage(), + event.error, mUploadActionUseCase.isEligibleForAutoUpload(site, event.post))).toString(); + String notificationMessage = UploadUtils.getErrorMessage(context, event.post.isPage(), errorMessage, false); + mPostUploadNotifier.removePostInfoFromForegroundNotification(event.post, + mMediaStore.getMediaForPost(event.post)); + mPostUploadNotifier.incrementUploadedPostCountFromForegroundNotification(event.post); + mPostUploadNotifier.updateNotificationErrorForPost(event.post, site, notificationMessage, 0); + sFirstPublishPosts.remove(event.post.getId()); + } } else { mPostUploadNotifier.incrementUploadedPostCountFromForegroundNotification(event.post); boolean isFirstTimePublish = sFirstPublishPosts.remove(event.post.getId()); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadService.java b/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadService.java index d4225e5ae061..6217b1e4c559 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadService.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadService.java @@ -4,6 +4,7 @@ import android.content.Context; import android.content.Intent; import android.os.IBinder; +import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -1112,6 +1113,8 @@ private List getRetriableStandaloneMedia(SiteModel selectedSite) { @SuppressWarnings("unused") @Subscribe(threadMode = ThreadMode.MAIN, priority = 7) public void onPostUploaded(OnPostUploaded event) { + Log.d("myTest", "UploadService.onPostUploaded(), error = " + event.error.message); + stopServiceIfUploadsComplete(event.isError(), event.post); } @@ -1121,6 +1124,7 @@ public void onPostUploaded(OnPostUploaded event) { */ @Subscribe(threadMode = ThreadMode.MAIN, priority = 7) public void onPostChanged(OnPostChanged event) { + Log.d("myTest", "UploadService.onPostChanged()"); if (event.causeOfChange instanceof CauseOfOnPostChanged.RemoteAutoSavePost) { PostModel post = mPostStore.getPostByLocalPostId(((RemoteAutoSavePost) event.causeOfChange).getLocalPostId()); diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/ActionPerformer.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/ActionPerformer.kt index 8199b1285ce7..87a2ca1263ba 100644 --- a/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/ActionPerformer.kt +++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/ActionPerformer.kt @@ -1,5 +1,6 @@ package org.wordpress.android.viewmodel.pages +import android.util.Log import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch @@ -60,6 +61,8 @@ class ActionPerformer @Suppress("unused") @Subscribe(threadMode = ThreadMode.MAIN) fun onPostUploaded(event: OnPostUploaded) { + Log.d("myTest","ActionPerformer.onPostUploaded()") + // negative local page ID used as a temp remote post ID for local-only pages (assigned by the PageStore) val continuation = continuations[event.post.remotePostId to UPLOAD] ?: continuations[-event.post.id.toLong() to UPLOAD] @@ -69,6 +72,8 @@ class ActionPerformer @Suppress("unused") @Subscribe(threadMode = ThreadMode.MAIN) fun onPostChange(event: OnPostChanged) { + Log.d("myTest","ActionPerformer.onPostChanged()") + postCauseOfChangeToPostAction(event.causeOfChange)?.let { (remoteId, localId, eventType) -> // negative local page ID used as a temp remote post ID for local-only pages (assigned by the PageStore) val continuation = continuations[remoteId to eventType] ?: continuations[-localId.toLong() to eventType] diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/PageListEventListener.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/PageListEventListener.kt index 6376d7170940..472170ef001d 100644 --- a/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/PageListEventListener.kt +++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/PageListEventListener.kt @@ -1,5 +1,6 @@ package org.wordpress.android.viewmodel.pages +import android.util.Log import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job @@ -123,6 +124,8 @@ class PageListEventListener( @Suppress("unused") @Subscribe(threadMode = BACKGROUND) fun onPostUploaded(event: OnPostUploaded) { + Log.d("myTest","WPMainActivity.onPostUploaded()") + if (event.post != null && event.post.isPage && event.post.localSiteId == site.id) { uploadStatusChanged(LocalId(event.post.id)) handlePostUploadFinished(RemoteId(event.post.remotePostId), event.isError, event.isFirstTimePublish) diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostFetcher.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostFetcher.kt index b7178d74910d..c69052e999e5 100644 --- a/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostFetcher.kt +++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostFetcher.kt @@ -1,5 +1,6 @@ package org.wordpress.android.viewmodel.posts +import android.util.Log import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner @@ -57,6 +58,7 @@ class PostFetcher constructor( @Suppress("unused") @Subscribe(threadMode = ThreadMode.BACKGROUND) fun onPostChanged(event: OnPostChanged) { + Log.d("myTest","PostFetcher.onPostChanged()") (event.causeOfChange as? UpdatePost)?.let { updatePostCauseOfChange -> ongoingRequests.remove(RemoteId(updatePostCauseOfChange.remotePostId)) } From 9c9eb39e7efa788d938cc5940b28b00dae7ed092 Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Thu, 28 Mar 2024 22:29:14 +0200 Subject: [PATCH 03/28] Adds: post version conflict handling --- .../android/ui/posts/PostConflictResolver.kt | 23 +++++++++++++++++-- .../android/ui/posts/PostListMainViewModel.kt | 5 ++-- .../android/ui/posts/PostListType.kt | 3 ++- .../android/ui/posts/SavePostToDbUseCase.kt | 1 + .../ui/posts/editor/EditorActionsProvider.kt | 6 +++-- .../android/ui/uploads/PostUploadHandler.java | 2 ++ .../android/ui/uploads/UploadUtils.java | 2 ++ .../pages/CreatePageListItemLabelsUseCase.kt | 10 ++++++-- .../posts/PostListItemUiStateHelper.kt | 11 +++++---- WordPress/src/main/res/values/strings.xml | 1 + build.gradle | 2 +- 11 files changed, 51 insertions(+), 15 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt index 100a175e00bd..61fd2aeca8de 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt @@ -1,11 +1,15 @@ package org.wordpress.android.ui.posts +import android.util.Log import org.wordpress.android.R import org.wordpress.android.fluxc.Dispatcher import org.wordpress.android.fluxc.generated.PostActionBuilder import org.wordpress.android.fluxc.model.PostModel import org.wordpress.android.fluxc.model.SiteModel +import org.wordpress.android.fluxc.model.post.PostStatus +import org.wordpress.android.fluxc.store.PostStore.PostErrorType import org.wordpress.android.fluxc.store.PostStore.RemotePostPayload +import org.wordpress.android.fluxc.store.UploadStore import org.wordpress.android.ui.pages.SnackbarMessageHolder import org.wordpress.android.ui.utils.UiString.UiStringRes import org.wordpress.android.util.ToastUtils.Duration @@ -23,7 +27,8 @@ class PostConflictResolver( private val invalidateList: () -> Unit, private val checkNetworkConnection: () -> Boolean, private val showSnackbar: (SnackbarMessageHolder) -> Unit, - private val showToast: (ToastMessageHolder) -> Unit + private val showToast: (ToastMessageHolder) -> Unit, + private val uploadStore: UploadStore ) { private var originalPostCopyForConflictUndo: PostModel? = null private var localPostIdForFetchingRemoteVersionOfConflictedPost: Int? = null @@ -36,6 +41,12 @@ class PostConflictResolver( val post = getPostByLocalPostId.invoke(localPostId) if (post != null) { + // Todo: is there a case that we should turn to different status? + if (post.status == PostStatus.OLD_REVISION.toString()) { + post.setStatus(PostStatus.PUBLISHED.toString()) + post.error = null + uploadStore.clearUploadErrorForPost(post) + } originalPostCopyForConflictUndo = post.clone() dispatcher.dispatch(PostActionBuilder.newFetchPostAction(RemotePostPayload(post, site))) showToast.invoke(ToastMessageHolder(R.string.toast_conflict_updating_post, Duration.SHORT)) @@ -55,6 +66,13 @@ class PostConflictResolver( val post = getPostByLocalPostId.invoke(localPostId) ?: return + // Todo: is there a case that we should turn to different status? + if (post.status == PostStatus.OLD_REVISION.toString()) { + post.setStatus(PostStatus.PUBLISHED.toString()) + post.error = null + uploadStore.clearUploadErrorForPost(post) + } + // and now show a snackBar, acting as if the Post was pushed, but effectively push it after the snackbar is gone var isUndoed = false val undoAction = { @@ -82,10 +100,11 @@ class PostConflictResolver( } fun doesPostHaveUnhandledConflict(post: PostModel): Boolean { + val isOldRevision = post.status == PostStatus.OLD_REVISION.toString() // If we are fetching the remote version of a conflicted post, it means it's already being handled val isFetchingConflictedPost = localPostIdForFetchingRemoteVersionOfConflictedPost != null && localPostIdForFetchingRemoteVersionOfConflictedPost == post.id - return !isFetchingConflictedPost && PostUtils.isPostInConflictWithRemote(post) + return isOldRevision || (!isFetchingConflictedPost && PostUtils.isPostInConflictWithRemote(post)) } fun hasUnhandledAutoSave(post: PostModel): Boolean { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt index ec0afbb051f7..bbec90d412e4 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt @@ -82,7 +82,7 @@ class PostListMainViewModel @Inject constructor( private val savePostToDbUseCase: SavePostToDbUseCase, @Named(UI_THREAD) private val mainDispatcher: CoroutineDispatcher, @Named(BG_THREAD) private val bgDispatcher: CoroutineDispatcher, - private val uploadStarter: UploadStarter + private val uploadStarter: UploadStarter, ) : ViewModel(), CoroutineScope { private val lifecycleOwner = object : LifecycleOwner { val lifecycleRegistry = LifecycleRegistry(this) @@ -162,7 +162,8 @@ class PostListMainViewModel @Inject constructor( invalidateList = this::invalidateAllLists, checkNetworkConnection = this::checkNetworkConnection, showSnackbar = { _snackBarMessage.postValue(it) }, - showToast = { _toastMessage.postValue(it) } + showToast = { _toastMessage.postValue(it) }, + uploadStore = uploadStore ) } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListType.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListType.kt index 886e7d5383d1..81932b6bba06 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListType.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListType.kt @@ -2,6 +2,7 @@ package org.wordpress.android.ui.posts import org.wordpress.android.R import org.wordpress.android.fluxc.model.post.PostStatus +import org.wordpress.android.fluxc.model.post.PostStatus.OLD_REVISION import org.wordpress.android.fluxc.model.post.PostStatus.PRIVATE enum class PostListType(val postStatuses: List) { @@ -32,7 +33,7 @@ enum class PostListType(val postStatuses: List) { companion object { fun fromPostStatus(status: PostStatus): PostListType { return when (status) { - PostStatus.PUBLISHED, PRIVATE -> PUBLISHED + PostStatus.PUBLISHED, PRIVATE, OLD_REVISION -> PUBLISHED PostStatus.DRAFT, PostStatus.PENDING, PostStatus.UNKNOWN -> DRAFTS PostStatus.TRASHED -> TRASHED PostStatus.SCHEDULED -> SCHEDULED diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/SavePostToDbUseCase.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/SavePostToDbUseCase.kt index ca619ca549f6..78e090974251 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/SavePostToDbUseCase.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/SavePostToDbUseCase.kt @@ -35,6 +35,7 @@ class SavePostToDbUseCase post.setStatus(PostStatus.PENDING.toString()) PostStatus.DRAFT, PostStatus.PENDING, + PostStatus.OLD_REVISION, PostStatus.TRASHED -> { } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/EditorActionsProvider.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/EditorActionsProvider.kt index 920ff686e25f..d3c660bb7988 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/EditorActionsProvider.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/EditorActionsProvider.kt @@ -21,7 +21,7 @@ class EditorActionsProvider @Inject constructor() { PostStatus.SCHEDULED -> PrimaryEditorAction.SCHEDULE PostStatus.DRAFT -> PrimaryEditorAction.PUBLISH_NOW PostStatus.PENDING, PostStatus.TRASHED -> PrimaryEditorAction.SAVE - PostStatus.PUBLISHED -> + PostStatus.PUBLISHED, PostStatus.OLD_REVISION -> if (isLandingEditor) PrimaryEditorAction.CONTINUE else PrimaryEditorAction.UPDATE PostStatus.PRIVATE, PostStatus.UNKNOWN -> PrimaryEditorAction.UPDATE } @@ -39,6 +39,7 @@ class EditorActionsProvider @Inject constructor() { PrimaryEditorAction.SAVE } PostStatus.PUBLISHED, + PostStatus.OLD_REVISION, PostStatus.SCHEDULED, PostStatus.PRIVATE -> { AppLog.e( @@ -59,7 +60,7 @@ class EditorActionsProvider @Inject constructor() { when (postStatus) { PostStatus.DRAFT -> SecondaryEditorAction.SAVE PostStatus.PENDING, PostStatus.SCHEDULED -> SecondaryEditorAction.PUBLISH_NOW - PostStatus.PRIVATE, PostStatus.PUBLISHED -> SecondaryEditorAction.NONE + PostStatus.PRIVATE, PostStatus.PUBLISHED, PostStatus.OLD_REVISION -> SecondaryEditorAction.NONE PostStatus.TRASHED, PostStatus.UNKNOWN -> SecondaryEditorAction.SAVE_AS_DRAFT } } else { @@ -76,6 +77,7 @@ class EditorActionsProvider @Inject constructor() { SecondaryEditorAction.SAVE_AS_DRAFT } PostStatus.PUBLISHED, + PostStatus.OLD_REVISION, PostStatus.SCHEDULED, PostStatus.PRIVATE -> { AppLog.e( diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java index 5f6446b5b75f..58e3bd6ac56c 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java @@ -666,6 +666,8 @@ public void onPostUploaded(OnPostUploaded event) { if (event.error.type == PostStore.PostErrorType.OLD_REVISION) { Log.d("",""); + // todo pantelis : should I set a status here like "old_revision"? + // event.post.setStatus(); } else { Context context = WordPress.getContext(); String errorMessage = mUiHelpers.getTextOfUiString(context, diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadUtils.java b/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadUtils.java index 42993a53818b..69156e457842 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadUtils.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadUtils.java @@ -97,6 +97,8 @@ UiString getErrorMessageResIdFromPostError(PostStatus postStatus, boolean isPage case UNAUTHORIZED: return isPage ? new UiStringRes(R.string.error_refresh_unauthorized_pages) : new UiStringRes(R.string.error_refresh_unauthorized_posts); + case OLD_REVISION: + return new UiStringRes(R.string.local_post_is_conflicted); case UNSUPPORTED_ACTION: case INVALID_RESPONSE: case GENERIC_ERROR: diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/CreatePageListItemLabelsUseCase.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/CreatePageListItemLabelsUseCase.kt index cefbb827d2bd..37175e34de5b 100644 --- a/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/CreatePageListItemLabelsUseCase.kt +++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/CreatePageListItemLabelsUseCase.kt @@ -5,6 +5,7 @@ import org.wordpress.android.R import org.wordpress.android.fluxc.model.PostModel import org.wordpress.android.fluxc.model.post.PostStatus import org.wordpress.android.fluxc.model.post.PostStatus.DRAFT +import org.wordpress.android.fluxc.model.post.PostStatus.OLD_REVISION import org.wordpress.android.fluxc.model.post.PostStatus.PENDING import org.wordpress.android.fluxc.model.post.PostStatus.PRIVATE import org.wordpress.android.fluxc.model.post.PostStatus.PUBLISHED @@ -87,6 +88,11 @@ class CreatePageListItemLabelsUseCase @Inject constructor( "Developer error: This state shouldn't happen. Trashed pages is in " + "UploadWaitingForConnection state." ) + OLD_REVISION -> AppLog.e( + PAGES, + "Developer error: This state shouldn't happen. Pages should not be in " + + "OLD_REVISION state" + ) } } hasUnhandledConflicts -> labels.add(UiStringRes(R.string.local_page_is_conflicted)) @@ -140,14 +146,14 @@ class CreatePageListItemLabelsUseCase @Inject constructor( ): UiStringRes { return when { uploadUiState.isEligibleForAutoUpload -> when (postStatus) { - PUBLISHED -> UiStringRes(R.string.error_media_recover_page_not_published_retrying) + PUBLISHED, OLD_REVISION -> UiStringRes(R.string.error_media_recover_page_not_published_retrying) PRIVATE -> UiStringRes(R.string.error_media_recover_page_not_published_retrying_private) SCHEDULED -> UiStringRes(R.string.error_media_recover_page_not_scheduled_retrying) PENDING -> UiStringRes(R.string.error_media_recover_page_not_submitted_retrying) DRAFT, TRASHED, UNKNOWN -> UiStringRes(R.string.error_generic_error_retrying) } uploadUiState.retryWillPushChanges -> when (postStatus) { - PUBLISHED -> UiStringRes(R.string.error_media_recover_page_not_published) + PUBLISHED, OLD_REVISION -> UiStringRes(R.string.error_media_recover_page_not_published) PRIVATE -> UiStringRes(R.string.error_media_recover_page_not_published_private) SCHEDULED -> UiStringRes(R.string.error_media_recover_page_not_scheduled) PENDING -> UiStringRes(R.string.error_media_recover_page_not_submitted) diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostListItemUiStateHelper.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostListItemUiStateHelper.kt index 80cd6f65b413..4a8cb87de978 100644 --- a/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostListItemUiStateHelper.kt +++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostListItemUiStateHelper.kt @@ -12,6 +12,7 @@ import org.wordpress.android.fluxc.model.PostModel import org.wordpress.android.fluxc.model.SiteModel import org.wordpress.android.fluxc.model.post.PostStatus import org.wordpress.android.fluxc.model.post.PostStatus.DRAFT +import org.wordpress.android.fluxc.model.post.PostStatus.OLD_REVISION import org.wordpress.android.fluxc.model.post.PostStatus.PENDING import org.wordpress.android.fluxc.model.post.PostStatus.PRIVATE import org.wordpress.android.fluxc.model.post.PostStatus.PUBLISHED @@ -151,7 +152,7 @@ class PostListItemUiStateHelper @Inject constructor( ) } - UNKNOWN, PUBLISHED, DRAFT, PRIVATE, PENDING, SCHEDULED -> onAction.invoke( + UNKNOWN, PUBLISHED, DRAFT, PRIVATE, PENDING, SCHEDULED, OLD_REVISION -> onAction.invoke( post, BUTTON_EDIT, POST_LIST_ITEM_SELECTED @@ -200,7 +201,7 @@ class PostListItemUiStateHelper @Inject constructor( if (isSearch) { val postStatusText = when (postStatus) { UNKNOWN -> R.string.unknown - PUBLISHED -> R.string.post_status_post_published + PUBLISHED, OLD_REVISION -> R.string.post_status_post_published DRAFT -> R.string.post_status_draft PRIVATE -> R.string.post_status_post_private PENDING -> R.string.post_status_pending_review @@ -290,7 +291,7 @@ class PostListItemUiStateHelper @Inject constructor( private fun getWaitingForConnectionStatus(postStatus: PostStatus): UiString? { return when (postStatus) { - UNKNOWN, PUBLISHED -> (UiStringRes(R.string.post_waiting_for_connection_publish)) + UNKNOWN, PUBLISHED, OLD_REVISION -> (UiStringRes(R.string.post_waiting_for_connection_publish)) PRIVATE -> (UiStringRes(R.string.post_waiting_for_connection_private)) PENDING -> (UiStringRes(R.string.post_waiting_for_connection_pending)) SCHEDULED -> (UiStringRes(R.string.post_waiting_for_connection_scheduled)) @@ -365,7 +366,7 @@ class PostListItemUiStateHelper @Inject constructor( private fun getMediaUploadErrorMessage(uploadUiState: UploadFailed, postStatus: PostStatus): UiStringRes { return when { uploadUiState.isEligibleForAutoUpload -> when (postStatus) { - PUBLISHED -> UiStringRes(R.string.error_media_recover_post_not_published_retrying) + PUBLISHED, OLD_REVISION -> UiStringRes(R.string.error_media_recover_post_not_published_retrying) PRIVATE -> UiStringRes(R.string.error_media_recover_post_not_published_retrying_private) SCHEDULED -> UiStringRes(R.string.error_media_recover_post_not_scheduled_retrying) PENDING -> UiStringRes(R.string.error_media_recover_post_not_submitted_retrying) @@ -373,7 +374,7 @@ class PostListItemUiStateHelper @Inject constructor( } uploadUiState.retryWillPushChanges -> when (postStatus) { - PUBLISHED -> UiStringRes(R.string.error_media_recover_post_not_published) + PUBLISHED, OLD_REVISION -> UiStringRes(R.string.error_media_recover_post_not_published) PRIVATE -> UiStringRes(R.string.error_media_recover_post_not_published_private) SCHEDULED -> UiStringRes(R.string.error_media_recover_post_not_scheduled) PENDING -> UiStringRes(R.string.error_media_recover_post_not_submitted) diff --git a/WordPress/src/main/res/values/strings.xml b/WordPress/src/main/res/values/strings.xml index 184ef2237dfc..0c6fdc73df0e 100644 --- a/WordPress/src/main/res/values/strings.xml +++ b/WordPress/src/main/res/values/strings.xml @@ -1964,6 +1964,7 @@ An error occurred while restoring the post You don\'t have permission to view or edit pages + You don\'t have permission to view or edit posts Couldn\'t retrieve your profile Couldn\'t retrieve your account settings diff --git a/build.gradle b/build.gradle index 80c229d4c634..4dd82c81359b 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ ext { automatticTracksVersion = '3.5.0' gutenbergMobileVersion = 'v1.116.0-alpha2' wordPressAztecVersion = 'v2.1.1' - wordPressFluxCVersion = '2982-70e163307b6b6f0c4c4d3499c38cd5e66ae56a0e' + wordPressFluxCVersion = '2982-5327865bbd2b21837e5ba587a65ad425e9ca0190' wordPressLoginVersion = '1.14.1' wordPressPersistentEditTextVersion = '1.0.2' wordPressUtilsVersion = '3.14.0' From a1e049cc680210067a4759cd68a9b903a62cd7f0 Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Sat, 30 Mar 2024 20:34:33 +0200 Subject: [PATCH 04/28] wip --- .../android/ui/posts/PostConflictResolver.kt | 38 ++++++++++++------- .../android/ui/posts/PostListEventListener.kt | 4 +- .../android/ui/posts/PostListType.kt | 3 +- .../ui/posts/PostModelUploadStatusTracker.kt | 14 +++++++ .../android/ui/posts/SavePostToDbUseCase.kt | 1 - .../ui/posts/editor/EditorActionsProvider.kt | 6 +-- .../android/ui/uploads/PostUploadHandler.java | 2 - .../pages/CreatePageListItemLabelsUseCase.kt | 10 +---- .../pages/PostModelUploadUiStateUseCase.kt | 19 ++++++---- .../posts/PostListItemUiStateHelper.kt | 24 ++++++++---- build.gradle | 2 +- 11 files changed, 75 insertions(+), 48 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt index 61fd2aeca8de..cb107e555e50 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt @@ -41,12 +41,11 @@ class PostConflictResolver( val post = getPostByLocalPostId.invoke(localPostId) if (post != null) { - // Todo: is there a case that we should turn to different status? - if (post.status == PostStatus.OLD_REVISION.toString()) { - post.setStatus(PostStatus.PUBLISHED.toString()) - post.error = null - uploadStore.clearUploadErrorForPost(post) - } + + // todo : do we need something more here? + post.error = null + uploadStore.clearUploadErrorForPost(post) + originalPostCopyForConflictUndo = post.clone() dispatcher.dispatch(PostActionBuilder.newFetchPostAction(RemotePostPayload(post, site))) showToast.invoke(ToastMessageHolder(R.string.toast_conflict_updating_post, Duration.SHORT)) @@ -66,12 +65,10 @@ class PostConflictResolver( val post = getPostByLocalPostId.invoke(localPostId) ?: return - // Todo: is there a case that we should turn to different status? - if (post.status == PostStatus.OLD_REVISION.toString()) { - post.setStatus(PostStatus.PUBLISHED.toString()) - post.error = null - uploadStore.clearUploadErrorForPost(post) - } + // todo : do we need something more here? + post.error = null + uploadStore.clearUploadErrorForPost(post) + // and now show a snackBar, acting as if the Post was pushed, but effectively push it after the snackbar is gone var isUndoed = false @@ -100,11 +97,24 @@ class PostConflictResolver( } fun doesPostHaveUnhandledConflict(post: PostModel): Boolean { - val isOldRevision = post.status == PostStatus.OLD_REVISION.toString() + Log.d("uiState", "doesPostHaveUnhandledConflict() entered for post: ${post.title}") + var isOldRevision = false + val uploadError = uploadStore.getUploadErrorForPost(post) + if (uploadError != null) { + if (uploadError.postError.type == PostErrorType.OLD_REVISION) { + isOldRevision = true + } + } + /* val isOldRevision = uploadStore.getUploadErrorForPost(post)?.postError?.type.toString() == + PostErrorType.OLD_REVISION.toString()*/ + // If we are fetching the remote version of a conflicted post, it means it's already being handled val isFetchingConflictedPost = localPostIdForFetchingRemoteVersionOfConflictedPost != null && localPostIdForFetchingRemoteVersionOfConflictedPost == post.id - return isOldRevision || (!isFetchingConflictedPost && PostUtils.isPostInConflictWithRemote(post)) + val x = isOldRevision || (!isFetchingConflictedPost && PostUtils.isPostInConflictWithRemote(post)) + Log.d("uiState", "doesPostHaveUnhandledConflict() exited for post: ${post.title} with value: $x") + + return x } fun hasUnhandledAutoSave(post: PostModel): Boolean { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt index 8806c1fec179..5983c1c25a12 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt @@ -188,10 +188,10 @@ class PostListEventListener( fun onPostUploaded(event: OnPostUploaded) { Log.d("myTest","PostListEventListener.onPostUploaded(), error = ${event.error.message}") - if (event.isError && event.error.type == PostStore.PostErrorType.OLD_REVISION) { + /* if (event.isError && event.error.type == PostStore.PostErrorType.OLD_REVISION) { Log.d("","") return - } + }*/ if (event.post != null && event.post.localSiteId == site.id) { if (!isRemotePreviewingFromPostsList.invoke() && !isRemotePreviewingFromEditor(event.post)) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListType.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListType.kt index 81932b6bba06..886e7d5383d1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListType.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListType.kt @@ -2,7 +2,6 @@ package org.wordpress.android.ui.posts import org.wordpress.android.R import org.wordpress.android.fluxc.model.post.PostStatus -import org.wordpress.android.fluxc.model.post.PostStatus.OLD_REVISION import org.wordpress.android.fluxc.model.post.PostStatus.PRIVATE enum class PostListType(val postStatuses: List) { @@ -33,7 +32,7 @@ enum class PostListType(val postStatuses: List) { companion object { fun fromPostStatus(status: PostStatus): PostListType { return when (status) { - PostStatus.PUBLISHED, PRIVATE, OLD_REVISION -> PUBLISHED + PostStatus.PUBLISHED, PRIVATE -> PUBLISHED PostStatus.DRAFT, PostStatus.PENDING, PostStatus.UNKNOWN -> DRAFTS PostStatus.TRASHED -> TRASHED PostStatus.SCHEDULED -> SCHEDULED diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostModelUploadStatusTracker.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostModelUploadStatusTracker.kt index de4b9615d3ca..e3bf40724229 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostModelUploadStatusTracker.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostModelUploadStatusTracker.kt @@ -1,6 +1,7 @@ package org.wordpress.android.ui.posts import android.annotation.SuppressLint +import android.util.Log import org.wordpress.android.fluxc.model.PostModel import org.wordpress.android.fluxc.model.SiteModel import org.wordpress.android.fluxc.store.UploadStore @@ -30,8 +31,14 @@ class PostModelUploadStatusTracker @Inject constructor( private val uploadStatusMap = HashMap() fun getUploadStatus(post: PostModel, siteModel: SiteModel): PostListItemUploadStatus { + + // todo: den eketeleitai pote edw an exei klhthei kai faei fail meta uploadStatusMap[post.id]?.let { return it } + val uploadError = uploadStore.getUploadErrorForPost(post) + + Log.d("uiState", "PostModelUploadStatusTracker.getUploadStatus(): uploadError = $uploadError") + val isUploadingOrQueued = UploadService.isPostUploadingOrQueued(post) val hasInProgressMediaUpload = UploadService.hasInProgressMediaUploadsForPost(post) val newStatus = PostListItemUploadStatus( @@ -47,6 +54,13 @@ class PostModelUploadStatusTracker @Inject constructor( uploadWillPushChanges = uploadActionUseCase.uploadWillPushChanges(post) ) uploadStatusMap[post.id] = newStatus + + Log.d("uiState", "PostModelUploadStatusTracker.getUploadStatus(): returns status = " + + "isUploading = ${newStatus.isUploading}, uploadError = ${newStatus.uploadError}, " + + "isQueued = ${newStatus.isQueued}, " + + "isUploadFailed = ${newStatus.isUploadFailed}, " + + "isEligibleForAutoUpload = ${newStatus.isEligibleForAutoUpload}") + return newStatus } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/SavePostToDbUseCase.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/SavePostToDbUseCase.kt index 78e090974251..ca619ca549f6 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/SavePostToDbUseCase.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/SavePostToDbUseCase.kt @@ -35,7 +35,6 @@ class SavePostToDbUseCase post.setStatus(PostStatus.PENDING.toString()) PostStatus.DRAFT, PostStatus.PENDING, - PostStatus.OLD_REVISION, PostStatus.TRASHED -> { } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/EditorActionsProvider.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/EditorActionsProvider.kt index d3c660bb7988..920ff686e25f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/EditorActionsProvider.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/EditorActionsProvider.kt @@ -21,7 +21,7 @@ class EditorActionsProvider @Inject constructor() { PostStatus.SCHEDULED -> PrimaryEditorAction.SCHEDULE PostStatus.DRAFT -> PrimaryEditorAction.PUBLISH_NOW PostStatus.PENDING, PostStatus.TRASHED -> PrimaryEditorAction.SAVE - PostStatus.PUBLISHED, PostStatus.OLD_REVISION -> + PostStatus.PUBLISHED -> if (isLandingEditor) PrimaryEditorAction.CONTINUE else PrimaryEditorAction.UPDATE PostStatus.PRIVATE, PostStatus.UNKNOWN -> PrimaryEditorAction.UPDATE } @@ -39,7 +39,6 @@ class EditorActionsProvider @Inject constructor() { PrimaryEditorAction.SAVE } PostStatus.PUBLISHED, - PostStatus.OLD_REVISION, PostStatus.SCHEDULED, PostStatus.PRIVATE -> { AppLog.e( @@ -60,7 +59,7 @@ class EditorActionsProvider @Inject constructor() { when (postStatus) { PostStatus.DRAFT -> SecondaryEditorAction.SAVE PostStatus.PENDING, PostStatus.SCHEDULED -> SecondaryEditorAction.PUBLISH_NOW - PostStatus.PRIVATE, PostStatus.PUBLISHED, PostStatus.OLD_REVISION -> SecondaryEditorAction.NONE + PostStatus.PRIVATE, PostStatus.PUBLISHED -> SecondaryEditorAction.NONE PostStatus.TRASHED, PostStatus.UNKNOWN -> SecondaryEditorAction.SAVE_AS_DRAFT } } else { @@ -77,7 +76,6 @@ class EditorActionsProvider @Inject constructor() { SecondaryEditorAction.SAVE_AS_DRAFT } PostStatus.PUBLISHED, - PostStatus.OLD_REVISION, PostStatus.SCHEDULED, PostStatus.PRIVATE -> { AppLog.e( diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java index 58e3bd6ac56c..5f6446b5b75f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java @@ -666,8 +666,6 @@ public void onPostUploaded(OnPostUploaded event) { if (event.error.type == PostStore.PostErrorType.OLD_REVISION) { Log.d("",""); - // todo pantelis : should I set a status here like "old_revision"? - // event.post.setStatus(); } else { Context context = WordPress.getContext(); String errorMessage = mUiHelpers.getTextOfUiString(context, diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/CreatePageListItemLabelsUseCase.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/CreatePageListItemLabelsUseCase.kt index 37175e34de5b..cefbb827d2bd 100644 --- a/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/CreatePageListItemLabelsUseCase.kt +++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/CreatePageListItemLabelsUseCase.kt @@ -5,7 +5,6 @@ import org.wordpress.android.R import org.wordpress.android.fluxc.model.PostModel import org.wordpress.android.fluxc.model.post.PostStatus import org.wordpress.android.fluxc.model.post.PostStatus.DRAFT -import org.wordpress.android.fluxc.model.post.PostStatus.OLD_REVISION import org.wordpress.android.fluxc.model.post.PostStatus.PENDING import org.wordpress.android.fluxc.model.post.PostStatus.PRIVATE import org.wordpress.android.fluxc.model.post.PostStatus.PUBLISHED @@ -88,11 +87,6 @@ class CreatePageListItemLabelsUseCase @Inject constructor( "Developer error: This state shouldn't happen. Trashed pages is in " + "UploadWaitingForConnection state." ) - OLD_REVISION -> AppLog.e( - PAGES, - "Developer error: This state shouldn't happen. Pages should not be in " + - "OLD_REVISION state" - ) } } hasUnhandledConflicts -> labels.add(UiStringRes(R.string.local_page_is_conflicted)) @@ -146,14 +140,14 @@ class CreatePageListItemLabelsUseCase @Inject constructor( ): UiStringRes { return when { uploadUiState.isEligibleForAutoUpload -> when (postStatus) { - PUBLISHED, OLD_REVISION -> UiStringRes(R.string.error_media_recover_page_not_published_retrying) + PUBLISHED -> UiStringRes(R.string.error_media_recover_page_not_published_retrying) PRIVATE -> UiStringRes(R.string.error_media_recover_page_not_published_retrying_private) SCHEDULED -> UiStringRes(R.string.error_media_recover_page_not_scheduled_retrying) PENDING -> UiStringRes(R.string.error_media_recover_page_not_submitted_retrying) DRAFT, TRASHED, UNKNOWN -> UiStringRes(R.string.error_generic_error_retrying) } uploadUiState.retryWillPushChanges -> when (postStatus) { - PUBLISHED, OLD_REVISION -> UiStringRes(R.string.error_media_recover_page_not_published) + PUBLISHED -> UiStringRes(R.string.error_media_recover_page_not_published) PRIVATE -> UiStringRes(R.string.error_media_recover_page_not_published_private) SCHEDULED -> UiStringRes(R.string.error_media_recover_page_not_scheduled) PENDING -> UiStringRes(R.string.error_media_recover_page_not_submitted) diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/PostModelUploadUiStateUseCase.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/PostModelUploadUiStateUseCase.kt index aec9832dae32..70ff7a102c09 100644 --- a/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/PostModelUploadUiStateUseCase.kt +++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/PostModelUploadUiStateUseCase.kt @@ -1,5 +1,6 @@ package org.wordpress.android.viewmodel.pages +import android.util.Log import org.wordpress.android.fluxc.model.PostModel import org.wordpress.android.fluxc.model.SiteModel import org.wordpress.android.fluxc.model.post.PostStatus @@ -25,25 +26,29 @@ class PostModelUploadUiStateUseCase @Inject constructor() { ): PostUploadUiState { val postStatus = PostStatus.fromPost(post) val uploadStatus = uploadStatusTracker.getUploadStatus(post, site) - return when { - uploadStatus.hasInProgressMediaUpload -> UploadingMedia( - uploadStatus.mediaUploadProgress - ) - uploadStatus.isUploading -> UploadingPost( - postStatus == DRAFT - ) + val x = when { // the upload error is not null on retry -> it needs to be evaluated after UploadingMedia and UploadingPost uploadStatus.uploadError != null -> UploadFailed( uploadStatus.uploadError, uploadStatus.isEligibleForAutoUpload, uploadStatus.uploadWillPushChanges ) + uploadStatus.hasInProgressMediaUpload -> UploadingMedia( + uploadStatus.mediaUploadProgress + ) + uploadStatus.isUploading -> UploadingPost( + postStatus == DRAFT + ) uploadStatus.hasPendingMediaUpload || uploadStatus.isQueued || uploadStatus.isUploadingOrQueued -> UploadQueued uploadStatus.isEligibleForAutoUpload -> UploadWaitingForConnection(postStatus) else -> NothingToUpload } + + Log.d("uiState", "PostModelUploadUiStateUseCase.createUploadUiState(): returns PostUploadUiState = $x") + + return x } /** diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostListItemUiStateHelper.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostListItemUiStateHelper.kt index 4a8cb87de978..ea083ebb51d2 100644 --- a/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostListItemUiStateHelper.kt +++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostListItemUiStateHelper.kt @@ -1,5 +1,6 @@ package org.wordpress.android.viewmodel.posts +import android.util.Log import org.apache.commons.text.StringEscapeUtils import org.wordpress.android.BuildConfig import org.wordpress.android.R @@ -12,7 +13,6 @@ import org.wordpress.android.fluxc.model.PostModel import org.wordpress.android.fluxc.model.SiteModel import org.wordpress.android.fluxc.model.post.PostStatus import org.wordpress.android.fluxc.model.post.PostStatus.DRAFT -import org.wordpress.android.fluxc.model.post.PostStatus.OLD_REVISION import org.wordpress.android.fluxc.model.post.PostStatus.PENDING import org.wordpress.android.fluxc.model.post.PostStatus.PRIVATE import org.wordpress.android.fluxc.model.post.PostStatus.PUBLISHED @@ -97,6 +97,9 @@ class PostListItemUiStateHelper @Inject constructor( val postStatus: PostStatus = PostStatus.fromPost(post) val uploadUiState = uploadUiStateUseCase.createUploadUiState(post, site, uploadStatusTracker) + Log.d("uiState", "PostListItemUiStateHelper.createPostListItemUiState(): uploadUiState = $uploadUiState") + + val onButtonClicked = { buttonType: PostListButtonType -> onAction.invoke(post, buttonType, POST_LIST_BUTTON_PRESSED) } @@ -152,7 +155,7 @@ class PostListItemUiStateHelper @Inject constructor( ) } - UNKNOWN, PUBLISHED, DRAFT, PRIVATE, PENDING, SCHEDULED, OLD_REVISION -> onAction.invoke( + UNKNOWN, PUBLISHED, DRAFT, PRIVATE, PENDING, SCHEDULED -> onAction.invoke( post, BUTTON_EDIT, POST_LIST_ITEM_SELECTED @@ -180,11 +183,18 @@ class PostListItemUiStateHelper @Inject constructor( disableRippleEffect = postStatus == TRASHED ) - return PostListItemUiState( + val state = PostListItemUiState( data = itemUiData, moreActions = moreActions, onSelected = onSelected ) + + /*return PostListItemUiState( + data = itemUiData, + moreActions = moreActions, + onSelected = onSelected + )*/ + return state } @Suppress("LongParameterList") @@ -201,7 +211,7 @@ class PostListItemUiStateHelper @Inject constructor( if (isSearch) { val postStatusText = when (postStatus) { UNKNOWN -> R.string.unknown - PUBLISHED, OLD_REVISION -> R.string.post_status_post_published + PUBLISHED -> R.string.post_status_post_published DRAFT -> R.string.post_status_draft PRIVATE -> R.string.post_status_post_private PENDING -> R.string.post_status_pending_review @@ -291,7 +301,7 @@ class PostListItemUiStateHelper @Inject constructor( private fun getWaitingForConnectionStatus(postStatus: PostStatus): UiString? { return when (postStatus) { - UNKNOWN, PUBLISHED, OLD_REVISION -> (UiStringRes(R.string.post_waiting_for_connection_publish)) + UNKNOWN, PUBLISHED -> (UiStringRes(R.string.post_waiting_for_connection_publish)) PRIVATE -> (UiStringRes(R.string.post_waiting_for_connection_private)) PENDING -> (UiStringRes(R.string.post_waiting_for_connection_pending)) SCHEDULED -> (UiStringRes(R.string.post_waiting_for_connection_scheduled)) @@ -366,7 +376,7 @@ class PostListItemUiStateHelper @Inject constructor( private fun getMediaUploadErrorMessage(uploadUiState: UploadFailed, postStatus: PostStatus): UiStringRes { return when { uploadUiState.isEligibleForAutoUpload -> when (postStatus) { - PUBLISHED, OLD_REVISION -> UiStringRes(R.string.error_media_recover_post_not_published_retrying) + PUBLISHED -> UiStringRes(R.string.error_media_recover_post_not_published_retrying) PRIVATE -> UiStringRes(R.string.error_media_recover_post_not_published_retrying_private) SCHEDULED -> UiStringRes(R.string.error_media_recover_post_not_scheduled_retrying) PENDING -> UiStringRes(R.string.error_media_recover_post_not_submitted_retrying) @@ -374,7 +384,7 @@ class PostListItemUiStateHelper @Inject constructor( } uploadUiState.retryWillPushChanges -> when (postStatus) { - PUBLISHED, OLD_REVISION -> UiStringRes(R.string.error_media_recover_post_not_published) + PUBLISHED -> UiStringRes(R.string.error_media_recover_post_not_published) PRIVATE -> UiStringRes(R.string.error_media_recover_post_not_published_private) SCHEDULED -> UiStringRes(R.string.error_media_recover_post_not_scheduled) PENDING -> UiStringRes(R.string.error_media_recover_post_not_submitted) diff --git a/build.gradle b/build.gradle index 4dd82c81359b..80ee6df25560 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ ext { automatticTracksVersion = '3.5.0' gutenbergMobileVersion = 'v1.116.0-alpha2' wordPressAztecVersion = 'v2.1.1' - wordPressFluxCVersion = '2982-5327865bbd2b21837e5ba587a65ad425e9ca0190' + wordPressFluxCVersion = '2982-b07b2343c285804524c284149b5768b1e0759cf8' wordPressLoginVersion = '1.14.1' wordPressPersistentEditTextVersion = '1.0.2' wordPressUtilsVersion = '3.14.0' From e59119959f433baecf7502eac51d44fb22209f79 Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Mon, 1 Apr 2024 13:32:52 +0300 Subject: [PATCH 05/28] Removes: debugging logs --- .../java/org/wordpress/android/ui/main/WPMainActivity.java | 1 - .../java/org/wordpress/android/ui/mysite/MySiteViewModel.kt | 2 -- .../java/org/wordpress/android/ui/posts/EditPostActivity.java | 4 ---- .../org/wordpress/android/ui/posts/PostListEventListener.kt | 3 --- .../wordpress/android/ui/posts/editor/StorePostViewModel.kt | 4 ---- .../wordpress/android/ui/reader/ReaderPostListActivity.java | 2 -- .../wordpress/android/ui/reader/ReaderPostPagerActivity.java | 2 -- .../org/wordpress/android/ui/uploads/PostUploadHandler.java | 3 --- .../java/org/wordpress/android/ui/uploads/UploadService.java | 3 --- .../org/wordpress/android/viewmodel/pages/ActionPerformer.kt | 4 ---- .../android/viewmodel/pages/PageListEventListener.kt | 2 -- .../java/org/wordpress/android/viewmodel/posts/PostFetcher.kt | 1 - build.gradle | 2 +- 13 files changed, 1 insertion(+), 32 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java index 63603e8ad290..d789b7c1e073 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java @@ -1737,7 +1737,6 @@ private void initSelectedSite() { @SuppressWarnings("unused") @Subscribe(threadMode = ThreadMode.MAIN) public void onPostUploaded(OnPostUploaded event) { - Log.d("myTest", "WPMainActivity§.onPostUploaded()"); // WPMainActivity never stops listening for the Dispatcher events and as a result it tries to show the // SnackBar even when another activity is in the foreground. However, this has a tricky side effect, as if diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt index d533b6eaea42..1301397c8125 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt @@ -422,8 +422,6 @@ class MySiteViewModel @Inject constructor( // FluxC events @Subscribe(threadMode = MAIN) fun onPostUploaded(event: OnPostUploaded) { - Log.d("myTest","MySiteViewModel.onPostUploaded()") - if (!event.isError) { event.post?.let { if (event.post.answeredPromptId > 0 && event.isFirstTimePublish) { 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 3d0725b4cb66..f8b0c0688ea6 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 @@ -3673,8 +3673,6 @@ public void onMediaListFetched(OnMediaListFetched event) { @SuppressWarnings("unused") @Subscribe(threadMode = ThreadMode.MAIN) public void onPostChanged(OnPostChanged event) { - Log.d("myTest", "EditPostActivity.onPostChanged()"); - if (event.causeOfChange instanceof CauseOfOnPostChanged.UpdatePost) { if (!event.isError()) { // here update the menu if it's not a draft anymore @@ -3748,8 +3746,6 @@ private void handleRemotePreviewUploadResult(boolean isError, RemotePreviewLogic @SuppressWarnings("unused") @Subscribe(threadMode = ThreadMode.MAIN) public void onPostUploaded(OnPostUploaded event) { - Log.d("myTest", "EditPostActivity.onPostUploaded()"); - final PostModel post = event.post; if (post != null && post.getId() == mEditPostRepository.getId()) { if (!isRemotePreviewingFromEditor()) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt index 5983c1c25a12..67a2caa92262 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt @@ -105,8 +105,6 @@ class PostListEventListener( @Suppress("unused", "LongMethod", "ComplexMethod") @Subscribe(threadMode = MAIN, priority = 5) fun onPostChanged(event: OnPostChanged) { - Log.d("myTest","PostListEventListener.onPostChanged()") - // We need to subscribe on the MAIN thread, in order to ensure the priority parameter is taken into account. // However, we want to perform the body of the method on a background thread. launch { @@ -186,7 +184,6 @@ class PostListEventListener( @Suppress("unused") @Subscribe(threadMode = BACKGROUND) fun onPostUploaded(event: OnPostUploaded) { - Log.d("myTest","PostListEventListener.onPostUploaded(), error = ${event.error.message}") /* if (event.isError && event.error.type == PostStore.PostErrorType.OLD_REVISION) { Log.d("","") diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/StorePostViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/StorePostViewModel.kt index 694dc146c9f4..b1c88246fbf2 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/StorePostViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/StorePostViewModel.kt @@ -220,16 +220,12 @@ class StorePostViewModel @Suppress("unused", "UNUSED_PARAMETER") @Subscribe fun onPostUploaded(event: OnPostUploaded) { - Log.d("myTest","StorePostViewModel.onPostUploaded(), error = ${event.error.message}") - hideSavingProgressDialog() } @Suppress("unused", "UNUSED_PARAMETER") @Subscribe fun onPostChanged(event: OnPostChanged) { - Log.d("myTest","StorePostViewModel.onPostChanged()") - hideSavingProgressDialog() // Refresh post content if needed diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java index 872c9f3397c0..dc404028a4ae 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java @@ -357,8 +357,6 @@ public void onClick(View v) { @SuppressWarnings("unused") @Subscribe(threadMode = ThreadMode.MAIN) public void onPostUploaded(OnPostUploaded event) { - Log.d("myTest", "ReaderPostListActivity.onPostUploaded()"); - SiteModel site = mSiteStore.getSiteByLocalId(mSelectedSiteRepository.getSelectedSiteLocalId()); if (site != null && event.post != null) { mUploadUtilsWrapper.onPostUploadedSnackbarHandler( diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java index ea639ecc2282..24714990ee39 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java @@ -1116,8 +1116,6 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { @SuppressWarnings("unused") @Subscribe(threadMode = ThreadMode.MAIN) public void onPostUploaded(OnPostUploaded event) { - Log.d("myTest", "ReaderPostPagerActivity.onPostUploaded()"); - SiteModel site = mSiteStore.getSiteByLocalId(mSelectedSiteRepository.getSelectedSiteLocalId()); if (site != null && event.post != null) { mUploadUtilsWrapper.onPostUploadedSnackbarHandler( diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java index 5f6446b5b75f..cd4ef9741c9a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java @@ -651,9 +651,6 @@ public void handleAutoSavePostIfNotDraftResult(@NonNull AutoSavePostIfNotDraftRe @SuppressWarnings("unused") @Subscribe(threadMode = ThreadMode.MAIN, priority = 9) public void onPostUploaded(OnPostUploaded event) { - Log.d("myTest", "PostUploadHandler.onPostUploaded(), error = " + event.error.message); - - // check if the event is related to the PostModel that is being uploaded by PostUploadHandler if (!isPostUploading(event.post)) { return; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadService.java b/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadService.java index 6217b1e4c559..afc1b69e7024 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadService.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadService.java @@ -1113,8 +1113,6 @@ private List getRetriableStandaloneMedia(SiteModel selectedSite) { @SuppressWarnings("unused") @Subscribe(threadMode = ThreadMode.MAIN, priority = 7) public void onPostUploaded(OnPostUploaded event) { - Log.d("myTest", "UploadService.onPostUploaded(), error = " + event.error.message); - stopServiceIfUploadsComplete(event.isError(), event.post); } @@ -1124,7 +1122,6 @@ public void onPostUploaded(OnPostUploaded event) { */ @Subscribe(threadMode = ThreadMode.MAIN, priority = 7) public void onPostChanged(OnPostChanged event) { - Log.d("myTest", "UploadService.onPostChanged()"); if (event.causeOfChange instanceof CauseOfOnPostChanged.RemoteAutoSavePost) { PostModel post = mPostStore.getPostByLocalPostId(((RemoteAutoSavePost) event.causeOfChange).getLocalPostId()); diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/ActionPerformer.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/ActionPerformer.kt index 87a2ca1263ba..9a7de9949746 100644 --- a/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/ActionPerformer.kt +++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/ActionPerformer.kt @@ -61,8 +61,6 @@ class ActionPerformer @Suppress("unused") @Subscribe(threadMode = ThreadMode.MAIN) fun onPostUploaded(event: OnPostUploaded) { - Log.d("myTest","ActionPerformer.onPostUploaded()") - // negative local page ID used as a temp remote post ID for local-only pages (assigned by the PageStore) val continuation = continuations[event.post.remotePostId to UPLOAD] ?: continuations[-event.post.id.toLong() to UPLOAD] @@ -72,8 +70,6 @@ class ActionPerformer @Suppress("unused") @Subscribe(threadMode = ThreadMode.MAIN) fun onPostChange(event: OnPostChanged) { - Log.d("myTest","ActionPerformer.onPostChanged()") - postCauseOfChangeToPostAction(event.causeOfChange)?.let { (remoteId, localId, eventType) -> // negative local page ID used as a temp remote post ID for local-only pages (assigned by the PageStore) val continuation = continuations[remoteId to eventType] ?: continuations[-localId.toLong() to eventType] diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/PageListEventListener.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/PageListEventListener.kt index 472170ef001d..01259b7d41ff 100644 --- a/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/PageListEventListener.kt +++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/PageListEventListener.kt @@ -124,8 +124,6 @@ class PageListEventListener( @Suppress("unused") @Subscribe(threadMode = BACKGROUND) fun onPostUploaded(event: OnPostUploaded) { - Log.d("myTest","WPMainActivity.onPostUploaded()") - if (event.post != null && event.post.isPage && event.post.localSiteId == site.id) { uploadStatusChanged(LocalId(event.post.id)) handlePostUploadFinished(RemoteId(event.post.remotePostId), event.isError, event.isFirstTimePublish) diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostFetcher.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostFetcher.kt index c69052e999e5..c950c15debc1 100644 --- a/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostFetcher.kt +++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostFetcher.kt @@ -58,7 +58,6 @@ class PostFetcher constructor( @Suppress("unused") @Subscribe(threadMode = ThreadMode.BACKGROUND) fun onPostChanged(event: OnPostChanged) { - Log.d("myTest","PostFetcher.onPostChanged()") (event.causeOfChange as? UpdatePost)?.let { updatePostCauseOfChange -> ongoingRequests.remove(RemoteId(updatePostCauseOfChange.remotePostId)) } diff --git a/build.gradle b/build.gradle index 80ee6df25560..a3e1763954f5 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ ext { automatticTracksVersion = '3.5.0' gutenbergMobileVersion = 'v1.116.0-alpha2' wordPressAztecVersion = 'v2.1.1' - wordPressFluxCVersion = '2982-b07b2343c285804524c284149b5768b1e0759cf8' + wordPressFluxCVersion = '2982-fdfec064f0b3494a2465b0b9e027f17bb76e3a26' wordPressLoginVersion = '1.14.1' wordPressPersistentEditTextVersion = '1.0.2' wordPressUtilsVersion = '3.14.0' From 4c93500e3c3883c7a50656797757895582705d3c Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Mon, 1 Apr 2024 13:35:00 +0300 Subject: [PATCH 06/28] Modifies: PostConflictResolver --- .../android/ui/posts/PostConflictResolver.kt | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt index cb107e555e50..4da2ff40deff 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt @@ -6,7 +6,6 @@ import org.wordpress.android.fluxc.Dispatcher import org.wordpress.android.fluxc.generated.PostActionBuilder import org.wordpress.android.fluxc.model.PostModel import org.wordpress.android.fluxc.model.SiteModel -import org.wordpress.android.fluxc.model.post.PostStatus import org.wordpress.android.fluxc.store.PostStore.PostErrorType import org.wordpress.android.fluxc.store.PostStore.RemotePostPayload import org.wordpress.android.fluxc.store.UploadStore @@ -41,11 +40,8 @@ class PostConflictResolver( val post = getPostByLocalPostId.invoke(localPostId) if (post != null) { - - // todo : do we need something more here? post.error = null uploadStore.clearUploadErrorForPost(post) - originalPostCopyForConflictUndo = post.clone() dispatcher.dispatch(PostActionBuilder.newFetchPostAction(RemotePostPayload(post, site))) showToast.invoke(ToastMessageHolder(R.string.toast_conflict_updating_post, Duration.SHORT)) @@ -64,12 +60,9 @@ class PostConflictResolver( invalidateList.invoke() val post = getPostByLocalPostId.invoke(localPostId) ?: return - - // todo : do we need something more here? post.error = null uploadStore.clearUploadErrorForPost(post) - // and now show a snackBar, acting as if the Post was pushed, but effectively push it after the snackbar is gone var isUndoed = false val undoAction = { @@ -84,7 +77,9 @@ class PostConflictResolver( if (!isUndoed) { localPostIdForFetchingRemoteVersionOfConflictedPost = null PostUtils.trackSavePostAnalytics(post, site) - dispatcher.dispatch(PostActionBuilder.newPushPostAction(RemotePostPayload(post, site))) + val remotePostPayload = RemotePostPayload(post, site) + remotePostPayload.isConflictResolution = true + dispatcher.dispatch(PostActionBuilder.newPushPostAction(remotePostPayload)) } } val snackBarHolder = SnackbarMessageHolder( @@ -105,9 +100,7 @@ class PostConflictResolver( isOldRevision = true } } - /* val isOldRevision = uploadStore.getUploadErrorForPost(post)?.postError?.type.toString() == - PostErrorType.OLD_REVISION.toString()*/ - + // If we are fetching the remote version of a conflicted post, it means it's already being handled val isFetchingConflictedPost = localPostIdForFetchingRemoteVersionOfConflictedPost != null && localPostIdForFetchingRemoteVersionOfConflictedPost == post.id From cc93a3d967cf54fcf72f53bd9be79ab199f1356c Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Mon, 1 Apr 2024 15:27:02 +0300 Subject: [PATCH 07/28] Adds: showRetry option to onPostUploadedSnackbarHandler --- .../android/ui/posts/PostConflictResolver.kt | 2 +- .../android/ui/posts/PostListEventListener.kt | 33 ++++++++++++++----- .../android/ui/posts/PostUploadAction.kt | 6 ++-- .../android/ui/uploads/UploadUtils.java | 8 +++-- .../android/ui/uploads/UploadUtilsWrapper.kt | 6 ++-- 5 files changed, 38 insertions(+), 17 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt index 4da2ff40deff..b60afc8eea4c 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt @@ -100,7 +100,7 @@ class PostConflictResolver( isOldRevision = true } } - + // If we are fetching the remote version of a conflicted post, it means it's already being handled val isFetchingConflictedPost = localPostIdForFetchingRemoteVersionOfConflictedPost != null && localPostIdForFetchingRemoteVersionOfConflictedPost == post.id diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt index 67a2caa92262..9f2ca4c95e56 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt @@ -192,16 +192,31 @@ class PostListEventListener( if (event.post != null && event.post.localSiteId == site.id) { if (!isRemotePreviewingFromPostsList.invoke() && !isRemotePreviewingFromEditor(event.post)) { - triggerPostUploadAction.invoke( - PostUploadedSnackbar( - dispatcher, - site, - event.post, - event.isError, - event.isFirstTimePublish, - null + + if (event.error.type == PostStore.PostErrorType.OLD_REVISION) { + triggerPostUploadAction.invoke( + PostUploadedSnackbar( + dispatcher, + site, + event.post, + event.isError, + event.isFirstTimePublish, + event.error.message, + showRetry = false + ) ) - ) + } else { + triggerPostUploadAction.invoke( + PostUploadedSnackbar( + dispatcher, + site, + event.post, + event.isError, + event.isFirstTimePublish, + null + ) + ) + } } uploadStatusChanged(event.post.id) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostUploadAction.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostUploadAction.kt index 4feb417a253a..28c75e6747c0 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostUploadAction.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostUploadAction.kt @@ -29,7 +29,8 @@ sealed class PostUploadAction { val post: PostModel, val isError: Boolean, val isFirstTimePublish: Boolean, - val errorMessage: String? + val errorMessage: String?, + val showRetry: Boolean = true ) : PostUploadAction() class MediaUploadedSnackbar( @@ -89,7 +90,8 @@ fun handleUploadAction( action.post, action.errorMessage, action.site, - onPublishingCallback + onPublishingCallback, + action.showRetry ) } is PostUploadAction.MediaUploadedSnackbar -> { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadUtils.java b/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadUtils.java index 69156e457842..ebd9026db0af 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadUtils.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadUtils.java @@ -470,19 +470,21 @@ public static boolean userCanPublish(SiteModel site) { return !SiteUtils.isAccessedViaWPComRest(site) || site.getHasCapabilityPublishPosts(); } - public static void onPostUploadedSnackbarHandler(final Activity activity, View snackbarAttachView, + public static void onPostUploadedSnackbarHandler(final Activity activity, + View snackbarAttachView, boolean isError, boolean isFirstTimePublish, final PostModel post, final String errorMessage, final SiteModel site, final Dispatcher dispatcher, SnackbarSequencer sequencer, - @Nullable OnPublishingCallback onPublishingCallback) { + @Nullable OnPublishingCallback onPublishingCallback, + final boolean showRetry) { boolean userCanPublish = userCanPublish(site); if (isError) { if (errorMessage != null) { // RETRY only available for Aztec - if (AppPrefs.isAztecEditorEnabled()) { + if (AppPrefs.isAztecEditorEnabled() && showRetry) { UploadUtils.showSnackbarError(snackbarAttachView, errorMessage, R.string.retry, new View.OnClickListener() { @Override diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadUtilsWrapper.kt b/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadUtilsWrapper.kt index 0eda61cebad2..8ee2738e2d8f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadUtilsWrapper.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadUtilsWrapper.kt @@ -59,7 +59,8 @@ class UploadUtilsWrapper @Inject constructor( post: PostModel?, errorMessage: String?, site: SiteModel?, - onPublishingCallback: OnPublishingCallback? = null + onPublishingCallback: OnPublishingCallback? = null, + showRetry: Boolean = true ) = UploadUtils.onPostUploadedSnackbarHandler( activity, snackbarAttachView, @@ -70,7 +71,8 @@ class UploadUtilsWrapper @Inject constructor( site, dispatcher, sequencer, - onPublishingCallback + onPublishingCallback, + showRetry ) @JvmOverloads From 014bb9e3579301069d1221c4687a36e558c99b44 Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Mon, 1 Apr 2024 17:09:33 +0300 Subject: [PATCH 08/28] Fixes: nullPointerException errors --- .../org/wordpress/android/ui/posts/PostListEventListener.kt | 2 +- .../org/wordpress/android/ui/uploads/PostUploadHandler.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt index 9f2ca4c95e56..eccb147062e7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt @@ -193,7 +193,7 @@ class PostListEventListener( if (event.post != null && event.post.localSiteId == site.id) { if (!isRemotePreviewingFromPostsList.invoke() && !isRemotePreviewingFromEditor(event.post)) { - if (event.error.type == PostStore.PostErrorType.OLD_REVISION) { + if (event.isError && event.error.type == PostStore.PostErrorType.OLD_REVISION) { triggerPostUploadAction.invoke( PostUploadedSnackbar( dispatcher, diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java index cd4ef9741c9a..28f280f1774e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java @@ -661,7 +661,7 @@ public void onPostUploaded(OnPostUploaded event) { AppLog.w(T.POSTS, "PostUploadHandler > Post upload failed. " + event.error.type + ": " + event.error.message); - if (event.error.type == PostStore.PostErrorType.OLD_REVISION) { + if (event.isError() && event.error.type == PostStore.PostErrorType.OLD_REVISION) { Log.d("",""); } else { Context context = WordPress.getContext(); From a7e9cb74fdebe95b82bbbc0ac5d4b4c523434a8e Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Mon, 1 Apr 2024 18:06:27 +0300 Subject: [PATCH 09/28] Updates: PostConflictResolver --- .../java/org/wordpress/android/ui/posts/PostConflictResolver.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt index b60afc8eea4c..f99973245065 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt @@ -41,6 +41,7 @@ class PostConflictResolver( val post = getPostByLocalPostId.invoke(localPostId) if (post != null) { post.error = null + post.setIsLocallyChanged(false) uploadStore.clearUploadErrorForPost(post) originalPostCopyForConflictUndo = post.clone() dispatcher.dispatch(PostActionBuilder.newFetchPostAction(RemotePostPayload(post, site))) From fcb580d6dfa434257df9989961ad0451b6403227 Mon Sep 17 00:00:00 2001 From: Ajesh R Pai Date: Mon, 1 Apr 2024 21:07:54 +0530 Subject: [PATCH 10/28] + Adds: the logic to remove the local revision with remote version --- .../android/ui/posts/PostConflictResolver.kt | 21 ++++++++----------- .../android/ui/posts/PostListMainViewModel.kt | 3 ++- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt index cb107e555e50..590bda2a4b71 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt @@ -6,7 +6,7 @@ import org.wordpress.android.fluxc.Dispatcher import org.wordpress.android.fluxc.generated.PostActionBuilder import org.wordpress.android.fluxc.model.PostModel import org.wordpress.android.fluxc.model.SiteModel -import org.wordpress.android.fluxc.model.post.PostStatus +import org.wordpress.android.fluxc.store.PostStore import org.wordpress.android.fluxc.store.PostStore.PostErrorType import org.wordpress.android.fluxc.store.PostStore.RemotePostPayload import org.wordpress.android.fluxc.store.UploadStore @@ -28,7 +28,8 @@ class PostConflictResolver( private val checkNetworkConnection: () -> Boolean, private val showSnackbar: (SnackbarMessageHolder) -> Unit, private val showToast: (ToastMessageHolder) -> Unit, - private val uploadStore: UploadStore + private val uploadStore: UploadStore, + private val postStore: PostStore ) { private var originalPostCopyForConflictUndo: PostModel? = null private var localPostIdForFetchingRemoteVersionOfConflictedPost: Int? = null @@ -45,8 +46,12 @@ class PostConflictResolver( // todo : do we need something more here? post.error = null uploadStore.clearUploadErrorForPost(post) - + post.setIsLocallyChanged(false) + post.setAutoSaveExcerpt(null) + post.setAutoSaveRevisionId(0) + postStore.removeLocalRevision(post) originalPostCopyForConflictUndo = post.clone() + dispatcher.dispatch(PostActionBuilder.newFetchPostAction(RemotePostPayload(post, site))) showToast.invoke(ToastMessageHolder(R.string.toast_conflict_updating_post, Duration.SHORT)) } @@ -132,20 +137,12 @@ class PostConflictResolver( } private fun conflictedPostUpdatedWithRemoteVersion() { - val undoAction = { - // here replace the post with whatever we had before, again - if (originalPostCopyForConflictUndo != null) { - dispatcher.dispatch(PostActionBuilder.newUpdatePostAction(originalPostCopyForConflictUndo)) - } - } val onDismissAction = { _: Int -> originalPostCopyForConflictUndo = null } val snackBarHolder = SnackbarMessageHolder( UiStringRes(R.string.snackbar_conflict_local_version_discarded), - UiStringRes(R.string.snackbar_conflict_undo), - undoAction, - onDismissAction + onDismissAction = onDismissAction ) showSnackbar.invoke(snackBarHolder) } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt index bbec90d412e4..8ced8d0611d6 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt @@ -163,7 +163,8 @@ class PostListMainViewModel @Inject constructor( checkNetworkConnection = this::checkNetworkConnection, showSnackbar = { _snackBarMessage.postValue(it) }, showToast = { _toastMessage.postValue(it) }, - uploadStore = uploadStore + uploadStore = uploadStore, + postStore = postStore ) } From b24985bdf9c3e9940d8669e6080e3678c70d1a42 Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Tue, 2 Apr 2024 15:47:45 +0300 Subject: [PATCH 11/28] Modifies: fluxC lib version --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index a3e1763954f5..4fb7ee17fe94 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ ext { automatticTracksVersion = '3.5.0' gutenbergMobileVersion = 'v1.116.0-alpha2' wordPressAztecVersion = 'v2.1.1' - wordPressFluxCVersion = '2982-fdfec064f0b3494a2465b0b9e027f17bb76e3a26' + wordPressFluxCVersion = '2982-581a6f927307f470bf13c68f74270666c58de004' wordPressLoginVersion = '1.14.1' wordPressPersistentEditTextVersion = '1.0.2' wordPressUtilsVersion = '3.14.0' From e9d991594c2738bc8c2100731ca6a5aafa860f99 Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Tue, 2 Apr 2024 20:59:57 +0300 Subject: [PATCH 12/28] Modifies: Do not re-enqueue old-revision post --- .../android/ui/uploads/PostUploadHandler.java | 9 +++++++-- .../wordpress/android/ui/uploads/UploadService.java | 12 +++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java index 28f280f1774e..43f09f0a849a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java @@ -668,13 +668,18 @@ public void onPostUploaded(OnPostUploaded event) { String errorMessage = mUiHelpers.getTextOfUiString(context, UploadUtils.getErrorMessageResIdFromPostError(PostStatus.fromPost(event.post), event.post.isPage(), event.error, mUploadActionUseCase.isEligibleForAutoUpload(site, event.post))).toString(); - String notificationMessage = UploadUtils.getErrorMessage(context, event.post.isPage(), errorMessage, false); + String notificationMessage = UploadUtils.getErrorMessage( + context, + event.post.isPage(), + errorMessage, + false + ); mPostUploadNotifier.removePostInfoFromForegroundNotification(event.post, mMediaStore.getMediaForPost(event.post)); mPostUploadNotifier.incrementUploadedPostCountFromForegroundNotification(event.post); mPostUploadNotifier.updateNotificationErrorForPost(event.post, site, notificationMessage, 0); - sFirstPublishPosts.remove(event.post.getId()); } + sFirstPublishPosts.remove(event.post.getId()); } else { mPostUploadNotifier.incrementUploadedPostCountFromForegroundNotification(event.post); boolean isFirstTimePublish = sFirstPublishPosts.remove(event.post.getId()); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadService.java b/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadService.java index afc1b69e7024..de8f6bf387bd 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadService.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadService.java @@ -4,7 +4,6 @@ import android.content.Context; import android.content.Intent; import android.os.IBinder; -import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -31,9 +30,11 @@ import org.wordpress.android.fluxc.store.PostStore; import org.wordpress.android.fluxc.store.PostStore.OnPostChanged; import org.wordpress.android.fluxc.store.PostStore.OnPostUploaded; +import org.wordpress.android.fluxc.store.PostStore.PostErrorType; import org.wordpress.android.fluxc.store.SiteStore; import org.wordpress.android.fluxc.store.UploadStore; import org.wordpress.android.fluxc.store.UploadStore.ClearMediaPayload; +import org.wordpress.android.fluxc.store.UploadStore.UploadError; import org.wordpress.android.ui.media.services.MediaUploadReadyListener; import org.wordpress.android.ui.mysite.SelectedSiteRepository; import org.wordpress.android.ui.notifications.SystemNotificationsTracker; @@ -1051,6 +1052,15 @@ private boolean doFinalProcessingOfPosts(Boolean isError, PostModel post) { EventBus.getDefault().post( new PostEvents.PostUploadCanceled(postModel)); } else { + // Do not re-enqueue a post that has already failed with a version conflict + UploadError error = mUploadStore.getUploadErrorForPost(updatedPost); + if (error != null + && error.postError != null + && error.postError.type == PostErrorType.OLD_REVISION + ) { + continue; + } + // Do not re-enqueue a post that has already failed if (isError != null && isError && mUploadStore.isFailedPost(updatedPost)) { continue; From 67854bfa229900bec769d032cd73155063789ec5 Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Tue, 2 Apr 2024 21:00:16 +0300 Subject: [PATCH 13/28] Fixes: checkstyle issues --- .../org/wordpress/android/ui/main/WPMainActivity.java | 2 -- .../org/wordpress/android/ui/mysite/MySiteViewModel.kt | 1 - .../org/wordpress/android/ui/posts/EditPostActivity.java | 1 - .../wordpress/android/ui/posts/PostListEventListener.kt | 8 -------- .../android/ui/posts/PostModelUploadStatusTracker.kt | 1 - .../android/ui/posts/editor/StorePostViewModel.kt | 1 - .../android/ui/reader/ReaderPostListActivity.java | 1 - .../android/ui/reader/ReaderPostPagerActivity.java | 1 - .../wordpress/android/viewmodel/pages/ActionPerformer.kt | 1 - .../android/viewmodel/pages/PageListEventListener.kt | 1 - .../org/wordpress/android/viewmodel/posts/PostFetcher.kt | 1 - 11 files changed, 19 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java index d789b7c1e073..25afd022eb4a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java @@ -10,7 +10,6 @@ import android.os.Handler; import android.os.Looper; import android.text.TextUtils; -import android.util.Log; import android.view.HapticFeedbackConstants; import android.view.View; import android.view.ViewGroup; @@ -1737,7 +1736,6 @@ private void initSelectedSite() { @SuppressWarnings("unused") @Subscribe(threadMode = ThreadMode.MAIN) public void onPostUploaded(OnPostUploaded event) { - // WPMainActivity never stops listening for the Dispatcher events and as a result it tries to show the // SnackBar even when another activity is in the foreground. However, this has a tricky side effect, as if // the Activity in the foreground is showing a Snackbar the SnackBar is dismissed as soon as the diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt index 1301397c8125..6dcea39fc7a2 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt @@ -3,7 +3,6 @@ package org.wordpress.android.ui.mysite import android.net.Uri -import android.util.Log import androidx.annotation.StringRes import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData 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 f8b0c0688ea6..a3b23f033a2a 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 @@ -10,7 +10,6 @@ import android.os.Handler; import android.os.Looper; import android.text.TextUtils; -import android.util.Log; import android.view.DragEvent; import android.view.Menu; import android.view.MenuInflater; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt index eccb147062e7..16d7e3067a53 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListEventListener.kt @@ -1,6 +1,5 @@ package org.wordpress.android.ui.posts -import android.util.Log import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner @@ -184,15 +183,8 @@ class PostListEventListener( @Suppress("unused") @Subscribe(threadMode = BACKGROUND) fun onPostUploaded(event: OnPostUploaded) { - - /* if (event.isError && event.error.type == PostStore.PostErrorType.OLD_REVISION) { - Log.d("","") - return - }*/ - if (event.post != null && event.post.localSiteId == site.id) { if (!isRemotePreviewingFromPostsList.invoke() && !isRemotePreviewingFromEditor(event.post)) { - if (event.isError && event.error.type == PostStore.PostErrorType.OLD_REVISION) { triggerPostUploadAction.invoke( PostUploadedSnackbar( diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostModelUploadStatusTracker.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostModelUploadStatusTracker.kt index e3bf40724229..f1f2103665dc 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostModelUploadStatusTracker.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostModelUploadStatusTracker.kt @@ -31,7 +31,6 @@ class PostModelUploadStatusTracker @Inject constructor( private val uploadStatusMap = HashMap() fun getUploadStatus(post: PostModel, siteModel: SiteModel): PostListItemUploadStatus { - // todo: den eketeleitai pote edw an exei klhthei kai faei fail meta uploadStatusMap[post.id]?.let { return it } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/StorePostViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/StorePostViewModel.kt index b1c88246fbf2..684285199203 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/StorePostViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/editor/StorePostViewModel.kt @@ -1,7 +1,6 @@ package org.wordpress.android.ui.posts.editor import android.content.Context -import android.util.Log import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import kotlinx.coroutines.CoroutineDispatcher diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java index dc404028a4ae..0dae81b0e252 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java @@ -5,7 +5,6 @@ import android.content.ActivityNotFoundException; import android.content.Intent; import android.os.Bundle; -import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java index 24714990ee39..9f7f2de1c01c 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java @@ -7,7 +7,6 @@ import android.os.Bundle; import android.os.Parcelable; import android.text.TextUtils; -import android.util.Log; import android.util.SparseArray; import android.view.MenuItem; import android.view.View; diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/ActionPerformer.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/ActionPerformer.kt index 9a7de9949746..8199b1285ce7 100644 --- a/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/ActionPerformer.kt +++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/ActionPerformer.kt @@ -1,6 +1,5 @@ package org.wordpress.android.viewmodel.pages -import android.util.Log import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/PageListEventListener.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/PageListEventListener.kt index 01259b7d41ff..6376d7170940 100644 --- a/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/PageListEventListener.kt +++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/PageListEventListener.kt @@ -1,6 +1,5 @@ package org.wordpress.android.viewmodel.pages -import android.util.Log import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostFetcher.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostFetcher.kt index c950c15debc1..b7178d74910d 100644 --- a/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostFetcher.kt +++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostFetcher.kt @@ -1,6 +1,5 @@ package org.wordpress.android.viewmodel.posts -import android.util.Log import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner From 1ff833293107d0d029fbe4b9f92cfa223b404a4a Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Wed, 3 Apr 2024 12:45:30 +0300 Subject: [PATCH 14/28] Removes: undo action from PostConflictResolver --- .../android/ui/posts/PostConflictResolver.kt | 73 ++++--------------- 1 file changed, 16 insertions(+), 57 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt index ccb950769a14..ab35663c3f54 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt @@ -1,6 +1,5 @@ package org.wordpress.android.ui.posts -import android.util.Log import org.wordpress.android.R import org.wordpress.android.fluxc.Dispatcher import org.wordpress.android.fluxc.generated.PostActionBuilder @@ -31,8 +30,7 @@ class PostConflictResolver( private val uploadStore: UploadStore, private val postStore: PostStore ) { - private var originalPostCopyForConflictUndo: PostModel? = null - private var localPostIdForFetchingRemoteVersionOfConflictedPost: Int? = null + private var originalPostId: Int? = null fun updateConflictedPostWithRemoteVersion(localPostId: Int) { // We need network connection to load a remote post @@ -42,14 +40,12 @@ class PostConflictResolver( val post = getPostByLocalPostId.invoke(localPostId) if (post != null) { + originalPostId = post.id post.error = null post.setIsLocallyChanged(false) - uploadStore.clearUploadErrorForPost(post) - post.setIsLocallyChanged(false) post.setAutoSaveExcerpt(null) post.setAutoSaveRevisionId(0) postStore.removeLocalRevision(post) - originalPostCopyForConflictUndo = post.clone() dispatcher.dispatch(PostActionBuilder.newFetchPostAction(RemotePostPayload(post, site))) showToast.invoke(ToastMessageHolder(R.string.toast_conflict_updating_post, Duration.SHORT)) } @@ -61,70 +57,37 @@ class PostConflictResolver( return } - // Keep a reference to which post is being updated with the local version so we can avoid showing the conflicted - // label during the undo snackBar. - localPostIdForFetchingRemoteVersionOfConflictedPost = localPostId invalidateList.invoke() val post = getPostByLocalPostId.invoke(localPostId) ?: return post.error = null uploadStore.clearUploadErrorForPost(post) - // and now show a snackBar, acting as if the Post was pushed, but effectively push it after the snackbar is gone - var isUndoed = false - val undoAction = { - isUndoed = true - - // Remove the reference for the post being updated and re-show the conflicted label on undo - localPostIdForFetchingRemoteVersionOfConflictedPost = null - invalidateList.invoke() - } - - val onDismissAction = { _: Int -> - if (!isUndoed) { - localPostIdForFetchingRemoteVersionOfConflictedPost = null - PostUtils.trackSavePostAnalytics(post, site) - val remotePostPayload = RemotePostPayload(post, site) - remotePostPayload.isConflictResolution = true - dispatcher.dispatch(PostActionBuilder.newPushPostAction(remotePostPayload)) - } - } val snackBarHolder = SnackbarMessageHolder( - UiStringRes(R.string.snackbar_conflict_web_version_discarded), - UiStringRes(R.string.snackbar_conflict_undo), - undoAction, - onDismissAction + UiStringRes(R.string.snackbar_conflict_web_version_discarded) ) showSnackbar.invoke(snackBarHolder) - } - fun doesPostHaveUnhandledConflict(post: PostModel): Boolean { - Log.d("uiState", "doesPostHaveUnhandledConflict() entered for post: ${post.title}") - var isOldRevision = false - val uploadError = uploadStore.getUploadErrorForPost(post) - if (uploadError != null) { - if (uploadError.postError.type == PostErrorType.OLD_REVISION) { - isOldRevision = true - } - } - - // If we are fetching the remote version of a conflicted post, it means it's already being handled - val isFetchingConflictedPost = localPostIdForFetchingRemoteVersionOfConflictedPost != null && - localPostIdForFetchingRemoteVersionOfConflictedPost == post.id - val x = isOldRevision || (!isFetchingConflictedPost && PostUtils.isPostInConflictWithRemote(post)) - Log.d("uiState", "doesPostHaveUnhandledConflict() exited for post: ${post.title} with value: $x") - - return x + PostUtils.trackSavePostAnalytics(post, site) + val remotePostPayload = RemotePostPayload(post, site) + remotePostPayload.isConflictResolution = true + dispatcher.dispatch(PostActionBuilder.newPushPostAction(remotePostPayload)) } + fun doesPostHaveUnhandledConflict(post: PostModel): Boolean = + uploadStore.getUploadErrorForPost(post)?.postError?.type == PostErrorType.OLD_REVISION || + PostUtils.isPostInConflictWithRemote(post) + fun hasUnhandledAutoSave(post: PostModel): Boolean { return PostUtils.hasAutoSave(post) } fun onPostSuccessfullyUpdated() { - originalPostCopyForConflictUndo?.id?.let { - val updatedPost = getPostByLocalPostId.invoke(it) + originalPostId?.let { id -> + val updatedPost = getPostByLocalPostId.invoke(id) + originalPostId = null // Conflicted post has been successfully updated with its remote version + uploadStore.clearUploadErrorForPost(updatedPost) if (!PostUtils.isPostInConflictWithRemote(updatedPost)) { conflictedPostUpdatedWithRemoteVersion() } @@ -132,12 +95,8 @@ class PostConflictResolver( } private fun conflictedPostUpdatedWithRemoteVersion() { - val onDismissAction = { _: Int -> - originalPostCopyForConflictUndo = null - } val snackBarHolder = SnackbarMessageHolder( - UiStringRes(R.string.snackbar_conflict_local_version_discarded), - onDismissAction = onDismissAction + UiStringRes(R.string.snackbar_conflict_local_version_discarded) ) showSnackbar.invoke(snackBarHolder) } From aff276be91b9008d39fa18093fe264ad949e35b8 Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Wed, 3 Apr 2024 13:52:19 +0300 Subject: [PATCH 15/28] Fixes: checkstyle and detect issues --- .../android/ui/posts/PostListMainViewModel.kt | 2 +- .../ui/posts/PostModelUploadStatusTracker.kt | 13 ------------- .../android/ui/uploads/PostUploadHandler.java | 18 +++++++++++------- .../pages/PostModelUploadUiStateUseCase.kt | 7 +------ .../posts/PostListItemUiStateHelper.kt | 14 +------------- WordPress/src/main/res/values/strings.xml | 1 - 6 files changed, 14 insertions(+), 41 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt index 8ced8d0611d6..673c88f435b3 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt @@ -82,7 +82,7 @@ class PostListMainViewModel @Inject constructor( private val savePostToDbUseCase: SavePostToDbUseCase, @Named(UI_THREAD) private val mainDispatcher: CoroutineDispatcher, @Named(BG_THREAD) private val bgDispatcher: CoroutineDispatcher, - private val uploadStarter: UploadStarter, + private val uploadStarter: UploadStarter ) : ViewModel(), CoroutineScope { private val lifecycleOwner = object : LifecycleOwner { val lifecycleRegistry = LifecycleRegistry(this) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostModelUploadStatusTracker.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostModelUploadStatusTracker.kt index f1f2103665dc..de4b9615d3ca 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostModelUploadStatusTracker.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostModelUploadStatusTracker.kt @@ -1,7 +1,6 @@ package org.wordpress.android.ui.posts import android.annotation.SuppressLint -import android.util.Log import org.wordpress.android.fluxc.model.PostModel import org.wordpress.android.fluxc.model.SiteModel import org.wordpress.android.fluxc.store.UploadStore @@ -31,13 +30,8 @@ class PostModelUploadStatusTracker @Inject constructor( private val uploadStatusMap = HashMap() fun getUploadStatus(post: PostModel, siteModel: SiteModel): PostListItemUploadStatus { - // todo: den eketeleitai pote edw an exei klhthei kai faei fail meta uploadStatusMap[post.id]?.let { return it } - val uploadError = uploadStore.getUploadErrorForPost(post) - - Log.d("uiState", "PostModelUploadStatusTracker.getUploadStatus(): uploadError = $uploadError") - val isUploadingOrQueued = UploadService.isPostUploadingOrQueued(post) val hasInProgressMediaUpload = UploadService.hasInProgressMediaUploadsForPost(post) val newStatus = PostListItemUploadStatus( @@ -53,13 +47,6 @@ class PostModelUploadStatusTracker @Inject constructor( uploadWillPushChanges = uploadActionUseCase.uploadWillPushChanges(post) ) uploadStatusMap[post.id] = newStatus - - Log.d("uiState", "PostModelUploadStatusTracker.getUploadStatus(): returns status = " + - "isUploading = ${newStatus.isUploading}, uploadError = ${newStatus.uploadError}, " + - "isQueued = ${newStatus.isQueued}, " + - "isUploadFailed = ${newStatus.isUploadFailed}, " + - "isEligibleForAutoUpload = ${newStatus.isEligibleForAutoUpload}") - return newStatus } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java index 43f09f0a849a..376ba15a62a5 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java @@ -8,7 +8,6 @@ import android.provider.MediaStore.Images; import android.provider.MediaStore.Video; import android.text.TextUtils; -import android.util.Log; import android.util.SparseArray; import androidx.annotation.NonNull; @@ -661,13 +660,17 @@ public void onPostUploaded(OnPostUploaded event) { AppLog.w(T.POSTS, "PostUploadHandler > Post upload failed. " + event.error.type + ": " + event.error.message); - if (event.isError() && event.error.type == PostStore.PostErrorType.OLD_REVISION) { - Log.d("",""); - } else { + if (event.error.type != PostStore.PostErrorType.OLD_REVISION) { Context context = WordPress.getContext(); - String errorMessage = mUiHelpers.getTextOfUiString(context, - UploadUtils.getErrorMessageResIdFromPostError(PostStatus.fromPost(event.post), event.post.isPage(), - event.error, mUploadActionUseCase.isEligibleForAutoUpload(site, event.post))).toString(); + String errorMessage = mUiHelpers.getTextOfUiString( + context, + UploadUtils.getErrorMessageResIdFromPostError( + PostStatus.fromPost(event.post), + event.post.isPage(), + event.error, + mUploadActionUseCase.isEligibleForAutoUpload(site, event.post) + ) + ).toString(); String notificationMessage = UploadUtils.getErrorMessage( context, event.post.isPage(), @@ -679,6 +682,7 @@ public void onPostUploaded(OnPostUploaded event) { mPostUploadNotifier.incrementUploadedPostCountFromForegroundNotification(event.post); mPostUploadNotifier.updateNotificationErrorForPost(event.post, site, notificationMessage, 0); } + sFirstPublishPosts.remove(event.post.getId()); } else { mPostUploadNotifier.incrementUploadedPostCountFromForegroundNotification(event.post); diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/PostModelUploadUiStateUseCase.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/PostModelUploadUiStateUseCase.kt index 70ff7a102c09..e9d3f744d111 100644 --- a/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/PostModelUploadUiStateUseCase.kt +++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/pages/PostModelUploadUiStateUseCase.kt @@ -1,6 +1,5 @@ package org.wordpress.android.viewmodel.pages -import android.util.Log import org.wordpress.android.fluxc.model.PostModel import org.wordpress.android.fluxc.model.SiteModel import org.wordpress.android.fluxc.model.post.PostStatus @@ -26,7 +25,7 @@ class PostModelUploadUiStateUseCase @Inject constructor() { ): PostUploadUiState { val postStatus = PostStatus.fromPost(post) val uploadStatus = uploadStatusTracker.getUploadStatus(post, site) - val x = when { + return when { // the upload error is not null on retry -> it needs to be evaluated after UploadingMedia and UploadingPost uploadStatus.uploadError != null -> UploadFailed( uploadStatus.uploadError, @@ -45,10 +44,6 @@ class PostModelUploadUiStateUseCase @Inject constructor() { uploadStatus.isEligibleForAutoUpload -> UploadWaitingForConnection(postStatus) else -> NothingToUpload } - - Log.d("uiState", "PostModelUploadUiStateUseCase.createUploadUiState(): returns PostUploadUiState = $x") - - return x } /** diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostListItemUiStateHelper.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostListItemUiStateHelper.kt index ea083ebb51d2..025bdd4a2b93 100644 --- a/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostListItemUiStateHelper.kt +++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/posts/PostListItemUiStateHelper.kt @@ -1,6 +1,5 @@ package org.wordpress.android.viewmodel.posts -import android.util.Log import org.apache.commons.text.StringEscapeUtils import org.wordpress.android.BuildConfig import org.wordpress.android.R @@ -96,10 +95,6 @@ class PostListItemUiStateHelper @Inject constructor( ): PostListItemUiState { val postStatus: PostStatus = PostStatus.fromPost(post) val uploadUiState = uploadUiStateUseCase.createUploadUiState(post, site, uploadStatusTracker) - - Log.d("uiState", "PostListItemUiStateHelper.createPostListItemUiState(): uploadUiState = $uploadUiState") - - val onButtonClicked = { buttonType: PostListButtonType -> onAction.invoke(post, buttonType, POST_LIST_BUTTON_PRESSED) } @@ -183,18 +178,11 @@ class PostListItemUiStateHelper @Inject constructor( disableRippleEffect = postStatus == TRASHED ) - val state = PostListItemUiState( + return PostListItemUiState( data = itemUiData, moreActions = moreActions, onSelected = onSelected ) - - /*return PostListItemUiState( - data = itemUiData, - moreActions = moreActions, - onSelected = onSelected - )*/ - return state } @Suppress("LongParameterList") diff --git a/WordPress/src/main/res/values/strings.xml b/WordPress/src/main/res/values/strings.xml index 0c6fdc73df0e..184ef2237dfc 100644 --- a/WordPress/src/main/res/values/strings.xml +++ b/WordPress/src/main/res/values/strings.xml @@ -1964,7 +1964,6 @@ An error occurred while restoring the post You don\'t have permission to view or edit pages - You don\'t have permission to view or edit posts Couldn\'t retrieve your profile Couldn\'t retrieve your account settings From 57e956cc0cb6bb3250d431cf32fd6e006d3255a8 Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Wed, 3 Apr 2024 15:37:16 +0300 Subject: [PATCH 16/28] Handles: OLD_REVISION case in UploadActionUseCase --- .../org/wordpress/android/ui/uploads/UploadActionUseCase.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadActionUseCase.kt b/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadActionUseCase.kt index 24b9b37e7520..7eea6aac9909 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadActionUseCase.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/UploadActionUseCase.kt @@ -3,6 +3,7 @@ package org.wordpress.android.ui.uploads import dagger.Reusable import org.wordpress.android.fluxc.model.PostImmutableModel import org.wordpress.android.fluxc.model.SiteModel +import org.wordpress.android.fluxc.store.PostStore import org.wordpress.android.fluxc.store.UploadStore import org.wordpress.android.ui.posts.PostUtilsWrapper import org.wordpress.android.ui.uploads.UploadActionUseCase.UploadAction.DO_NOTHING @@ -39,7 +40,8 @@ class UploadActionUseCase @Inject constructor( } // Do not auto-upload post which is in conflict with remote - if (postUtilsWrapper.isPostInConflictWithRemote(post)) { + if (uploadStore.getUploadErrorForPost(post)?.postError?.type == PostStore.PostErrorType.OLD_REVISION + || postUtilsWrapper.isPostInConflictWithRemote(post)) { return DO_NOTHING } From cdf3809553603b745921baca3d82733179557a40 Mon Sep 17 00:00:00 2001 From: Annmarie Ziegler Date: Wed, 3 Apr 2024 16:34:56 -0400 Subject: [PATCH 17/28] Add unit tests for PostConflictResolver --- .../ui/posts/PostConflictResolverTest.kt | 150 ++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 WordPress/src/test/java/org/wordpress/android/ui/posts/PostConflictResolverTest.kt diff --git a/WordPress/src/test/java/org/wordpress/android/ui/posts/PostConflictResolverTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/posts/PostConflictResolverTest.kt new file mode 100644 index 000000000000..d11c70e090f0 --- /dev/null +++ b/WordPress/src/test/java/org/wordpress/android/ui/posts/PostConflictResolverTest.kt @@ -0,0 +1,150 @@ +package org.wordpress.android.ui.posts + +import kotlinx.coroutines.ExperimentalCoroutinesApi +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Before +import org.mockito.ArgumentMatchers.any +import org.mockito.ArgumentMatchers.anyInt +import org.mockito.Mockito.mock +import org.mockito.Mockito.verify +import org.mockito.kotlin.mock +import org.mockito.kotlin.verifyNoInteractions +import org.mockito.kotlin.whenever +import org.wordpress.android.BaseUnitTest +import org.wordpress.android.fluxc.Dispatcher +import org.wordpress.android.fluxc.model.PostModel +import org.wordpress.android.fluxc.model.SiteModel +import org.wordpress.android.fluxc.store.PostStore +import org.wordpress.android.fluxc.store.UploadStore +import org.wordpress.android.ui.pages.SnackbarMessageHolder +import org.wordpress.android.ui.utils.UiString +import org.wordpress.android.viewmodel.helpers.ToastMessageHolder +import kotlin.test.Test +import org.wordpress.android.R +import org.wordpress.android.util.ToastUtils + +@Suppress("UNCHECKED_CAST") +@ExperimentalCoroutinesApi +class PostConflictResolverTest : BaseUnitTest() { + private val dispatcher: Dispatcher = mock() + private val site: SiteModel = mock() + + private val getPostByLocalPostId = mock(Function1::class.java) as (Int) -> PostModel? + private val invalidateList = mock(Function0::class.java) as () -> Unit + private val checkNetworkConnection = mock(Function0::class.java) as () -> Boolean + private val showSnackbar = mock(Function1::class.java) as (SnackbarMessageHolder) -> Unit + private val showToast = mock(Function1::class.java) as (ToastMessageHolder) -> Unit + private val uploadStore: UploadStore = mock() + private val postStore: PostStore = mock() + + // Class under test + private lateinit var postConflictResolver: PostConflictResolver + + @Before + fun setUp() { + postConflictResolver = PostConflictResolver( + dispatcher, + site, + getPostByLocalPostId, + invalidateList, + checkNetworkConnection, + showSnackbar, + showToast, + uploadStore, + postStore + ) + } + + @Test + fun `given network connection, when update conflicted post with local version is invoked, then success`() { + whenever(checkNetworkConnection.invoke()).thenReturn(true) + val post = PostModel() + whenever(getPostByLocalPostId.invoke(anyInt())).thenReturn(post) + val expectedSnackbarMessage = SnackbarMessageHolder( + UiString.UiStringRes(R.string.snackbar_conflict_web_version_discarded) + ) + + postConflictResolver.updateConflictedPostWithLocalVersion(123) + + verify(invalidateList).invoke() + verify(uploadStore).clearUploadErrorForPost(post) + verify(showSnackbar).invoke(expectedSnackbarMessage) + verify(dispatcher).dispatch(any()) + } + + @Test + fun `given no network connection, when update conflicted post with local version is invoked, then no network`() { + whenever(checkNetworkConnection.invoke()).thenReturn(false) + + postConflictResolver.updateConflictedPostWithLocalVersion(123) + + verifyNoInteractions(getPostByLocalPostId) + verifyNoInteractions(postStore) + verifyNoInteractions(showSnackbar) + verifyNoInteractions(dispatcher) + } + + @Test + fun `given upload store with unhandled conflict, when does post have unhandled conflict is invoked, then true`() { + val post = PostModel() + whenever(uploadStore.getUploadErrorForPost(post)).thenReturn( + UploadStore.UploadError(PostStore.PostError(PostStore.PostErrorType.OLD_REVISION)) + ) + + val result = postConflictResolver.doesPostHaveUnhandledConflict(post) + + assertTrue(result) + } + + @Test + fun `given upload store with no unhandled conflict, when does post have unhandled conflict is invoked, then false`() { + val post = PostModel() + whenever(uploadStore.getUploadErrorForPost(post)).thenReturn(null) + + val result = postConflictResolver.doesPostHaveUnhandledConflict(post) + + assertFalse(result) + } + + @Test + fun `given post with unhandled auto save, when has unhandled auto save is invoked, then true`() { + val post = PostModel().apply { + setIsLocallyChanged(false) + setAutoSaveRevisionId(1) + setAutoSaveExcerpt("Some auto save excerpt") + } + + val result = postConflictResolver.hasUnhandledAutoSave(post) + + assertTrue(result) + } + + @Test + fun `given post with no unhandled auto save, when has unhandled auto save is invoked, then false`() { + val post = PostModel().apply { + setIsLocallyChanged(true) + } + + val result = postConflictResolver.hasUnhandledAutoSave(post) + + assertFalse(result) + } + + @Test + fun `given post is in conflict with remote, when on post updated, then clear upload error for post`() { + val updatedPost = PostModel() + whenever(getPostByLocalPostId.invoke(anyInt())).thenReturn(updatedPost) + whenever(checkNetworkConnection.invoke()).thenReturn(true) + val expectedSnackbarMessage = SnackbarMessageHolder( + UiString.UiStringRes(R.string.snackbar_conflict_local_version_discarded) + ) + + postConflictResolver.updateConflictedPostWithRemoteVersion(123) + postConflictResolver.onPostSuccessfullyUpdated() + + verify(uploadStore).clearUploadErrorForPost(updatedPost) + verify(showSnackbar).invoke(expectedSnackbarMessage) + } +} + From 8da18d65848ffdc10b0c2a351b7e2a58324887fc Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Thu, 4 Apr 2024 12:55:12 +0300 Subject: [PATCH 18/28] Hides 409 handling behind FF --- .../android/ui/posts/PostActionHandler.kt | 8 ++++++-- .../android/ui/posts/PostListMainViewModel.kt | 7 +++++-- .../android/ui/uploads/PostUploadHandler.java | 16 +++++++++++++--- .../config/SyncPublishingFeatureConfig.kt | 19 ++++++++++++++++++- 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostActionHandler.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostActionHandler.kt index 24baa0361c09..627f0f251371 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostActionHandler.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostActionHandler.kt @@ -30,6 +30,7 @@ import org.wordpress.android.ui.uploads.UploadService import org.wordpress.android.ui.uploads.UploadUtils import org.wordpress.android.ui.utils.UiString.UiStringRes import org.wordpress.android.util.ToastUtils.Duration +import org.wordpress.android.util.config.SyncPublishingFeatureConfig import org.wordpress.android.viewmodel.helpers.ToastMessageHolder import org.wordpress.android.widgets.PostListButtonType import org.wordpress.android.widgets.PostListButtonType.BUTTON_CANCEL_PENDING_AUTO_UPLOAD @@ -73,7 +74,8 @@ class PostActionHandler( private val showSnackbar: (SnackbarMessageHolder) -> Unit, private val showToast: (ToastMessageHolder) -> Unit, private val triggerPreviewStateUpdate: (PostListRemotePreviewState, PostInfoType) -> Unit, - private val copyPost: (SiteModel, PostModel, Boolean) -> Unit + private val copyPost: (SiteModel, PostModel, Boolean) -> Unit, + private val syncPublishingFeatureConfig: SyncPublishingFeatureConfig ) { private val criticalPostActionTracker = CriticalPostActionTracker(onStateChanged = { invalidateList.invoke() @@ -207,7 +209,9 @@ class PostActionHandler( return } post.setStatus(DRAFT.toString()) - dispatcher.dispatch(PostActionBuilder.newPushPostAction(RemotePostPayload(post, site))) + dispatcher.dispatch(PostActionBuilder.newPushPostAction( + syncPublishingFeatureConfig.getRemotePostPayloadForPush(RemotePostPayload(post, site)) + )) val localPostId = LocalId(post.id) criticalPostActionTracker.add(localPostId, MOVING_POST_TO_DRAFT) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt index 673c88f435b3..c5a09ecfb152 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt @@ -47,6 +47,7 @@ import org.wordpress.android.util.NetworkUtilsWrapper import org.wordpress.android.util.ToastUtils.Duration import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper import org.wordpress.android.util.analytics.AnalyticsUtils +import org.wordpress.android.util.config.SyncPublishingFeatureConfig import org.wordpress.android.viewmodel.Event import org.wordpress.android.viewmodel.SingleLiveEvent import org.wordpress.android.viewmodel.helpers.DialogHolder @@ -82,7 +83,8 @@ class PostListMainViewModel @Inject constructor( private val savePostToDbUseCase: SavePostToDbUseCase, @Named(UI_THREAD) private val mainDispatcher: CoroutineDispatcher, @Named(BG_THREAD) private val bgDispatcher: CoroutineDispatcher, - private val uploadStarter: UploadStarter + private val uploadStarter: UploadStarter, + private val syncPublishingFeatureConfig: SyncPublishingFeatureConfig ) : ViewModel(), CoroutineScope { private val lifecycleOwner = object : LifecycleOwner { val lifecycleRegistry = LifecycleRegistry(this) @@ -184,7 +186,8 @@ class PostListMainViewModel @Inject constructor( showSnackbar = { _snackBarMessage.postValue(it) }, showToast = { _toastMessage.postValue(it) }, triggerPreviewStateUpdate = this::updatePreviewAndDialogState, - copyPost = this::copyPost + copyPost = this::copyPost, + syncPublishingFeatureConfig = syncPublishingFeatureConfig ) } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java index 376ba15a62a5..d7bd93a86ecc 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java @@ -48,6 +48,7 @@ import org.wordpress.android.util.SiteUtils; import org.wordpress.android.util.SqlUtils; import org.wordpress.android.util.analytics.AnalyticsUtils; +import org.wordpress.android.util.config.SyncPublishingFeatureConfig; import org.wordpress.android.util.helpers.MediaFile; import java.io.File; @@ -83,6 +84,7 @@ public class PostUploadHandler implements UploadHandler, OnAutoSavePo @Inject UploadActionUseCase mUploadActionUseCase; @Inject AutoSavePostIfNotDraftUseCase mAutoSavePostIfNotDraftUseCase; @Inject PostMediaHandler mPostMediaHandler; + @Inject SyncPublishingFeatureConfig mSyncPublishingFeatureConfig; PostUploadHandler(PostUploadNotifier postUploadNotifier) { ((WordPress) WordPress.getContext().getApplicationContext()).component().inject(this); @@ -285,12 +287,18 @@ protected UploadPostTaskResult doInBackground(PostModel... posts) { switch (mUploadActionUseCase.getUploadAction(mPost)) { case UPLOAD: AppLog.d(T.POSTS, "PostUploadHandler - UPLOAD. Post: " + mPost.getTitle()); - mDispatcher.dispatch(PostActionBuilder.newPushPostAction(payload)); + mDispatcher.dispatch( + PostActionBuilder.newPushPostAction( + mSyncPublishingFeatureConfig.getRemotePostPayloadForPush(payload) + ) + ); break; case UPLOAD_AS_DRAFT: mPost.setStatus(PostStatus.DRAFT.toString()); AppLog.d(T.POSTS, "PostUploadHandler - UPLOAD_AS_DRAFT. Post: " + mPost.getTitle()); - mDispatcher.dispatch(PostActionBuilder.newPushPostAction(payload)); + mDispatcher.dispatch(PostActionBuilder.newPushPostAction( + mSyncPublishingFeatureConfig.getRemotePostPayloadForPush(payload) + )); break; case REMOTE_AUTO_SAVE: AppLog.d(T.POSTS, "PostUploadHandler - REMOTE_AUTO_SAVE. Post: " + mPost.getTitle()); @@ -637,7 +645,9 @@ public void handleAutoSavePostIfNotDraftResult(@NonNull AutoSavePostIfNotDraftRe */ post.setStatus(PostStatus.DRAFT.toString()); SiteModel site = mSiteStore.getSiteByLocalId(post.getLocalSiteId()); - mDispatcher.dispatch(PostActionBuilder.newPushPostAction(new RemotePostPayload(post, site))); + mDispatcher.dispatch(PostActionBuilder.newPushPostAction( + mSyncPublishingFeatureConfig.getRemotePostPayloadForPush(new RemotePostPayload(post, site)) + )); } else { throw new IllegalStateException("All AutoSavePostIfNotDraftResult types must be handled"); } diff --git a/WordPress/src/main/java/org/wordpress/android/util/config/SyncPublishingFeatureConfig.kt b/WordPress/src/main/java/org/wordpress/android/util/config/SyncPublishingFeatureConfig.kt index e1a4580e3b20..cca640b95b71 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/config/SyncPublishingFeatureConfig.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/config/SyncPublishingFeatureConfig.kt @@ -2,6 +2,7 @@ package org.wordpress.android.util.config import org.wordpress.android.BuildConfig import org.wordpress.android.annotation.Feature +import org.wordpress.android.fluxc.store.PostStore.RemotePostPayload import javax.inject.Inject private const val SYNC_PUBLISHING_FEATURE_REMOTE_FIELD = "sync_publishing" @@ -13,4 +14,20 @@ class SyncPublishingFeatureConfig @Inject constructor( appConfig, BuildConfig.SYNC_PUBLISHING, SYNC_PUBLISHING_FEATURE_REMOTE_FIELD -) +) { + /** + * This helper function aids in post-conflict resolution. When attempting to edit a post, + * sending the "if_not_modified_since" to the backend will trigger a 409 error if a newer version + * has already been uploaded from another device. This functionality should be encapsulated + * by the SYNC_PUBLISHING feature flag. The function is used to generate the final RemotePostPayload + * that is sent to the backend through PostActionBuilder.newPushPostAction(). By setting the + * isConflictResolution = true, "if_not_modified_since" is not sent to server and the post overwrites + * the remote version. + */ + fun getRemotePostPayloadForPush(payload: RemotePostPayload): RemotePostPayload { + if (this@SyncPublishingFeatureConfig.isEnabled().not()) { + payload.isConflictResolution = true + } + return payload + } +} From 05e3fe2e93dc43b9e5ae27a0731bed71123e06f6 Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Thu, 4 Apr 2024 14:08:17 +0300 Subject: [PATCH 19/28] Adds: SyncPublishingFeatureUtils --- .../android/ui/posts/PostActionHandler.kt | 4 +-- .../android/ui/posts/PostListMainViewModel.kt | 4 +-- .../ui/posts/SyncPublishingFeatureUtils.kt | 32 +++++++++++++++++++ .../android/ui/uploads/PostUploadHandler.java | 10 +++--- .../config/SyncPublishingFeatureConfig.kt | 19 +---------- 5 files changed, 42 insertions(+), 27 deletions(-) create mode 100644 WordPress/src/main/java/org/wordpress/android/ui/posts/SyncPublishingFeatureUtils.kt diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostActionHandler.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostActionHandler.kt index 627f0f251371..9c37c4b413fc 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostActionHandler.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostActionHandler.kt @@ -75,7 +75,7 @@ class PostActionHandler( private val showToast: (ToastMessageHolder) -> Unit, private val triggerPreviewStateUpdate: (PostListRemotePreviewState, PostInfoType) -> Unit, private val copyPost: (SiteModel, PostModel, Boolean) -> Unit, - private val syncPublishingFeatureConfig: SyncPublishingFeatureConfig + private val syncPublishingFeatureUtils: SyncPublishingFeatureUtils ) { private val criticalPostActionTracker = CriticalPostActionTracker(onStateChanged = { invalidateList.invoke() @@ -210,7 +210,7 @@ class PostActionHandler( } post.setStatus(DRAFT.toString()) dispatcher.dispatch(PostActionBuilder.newPushPostAction( - syncPublishingFeatureConfig.getRemotePostPayloadForPush(RemotePostPayload(post, site)) + syncPublishingFeatureUtils.getRemotePostPayloadForPush(RemotePostPayload(post, site)) )) val localPostId = LocalId(post.id) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt index c5a09ecfb152..c47cc9bcd1cb 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt @@ -84,7 +84,7 @@ class PostListMainViewModel @Inject constructor( @Named(UI_THREAD) private val mainDispatcher: CoroutineDispatcher, @Named(BG_THREAD) private val bgDispatcher: CoroutineDispatcher, private val uploadStarter: UploadStarter, - private val syncPublishingFeatureConfig: SyncPublishingFeatureConfig + private val syncPublishingFeatureUtils: SyncPublishingFeatureUtils ) : ViewModel(), CoroutineScope { private val lifecycleOwner = object : LifecycleOwner { val lifecycleRegistry = LifecycleRegistry(this) @@ -187,7 +187,7 @@ class PostListMainViewModel @Inject constructor( showToast = { _toastMessage.postValue(it) }, triggerPreviewStateUpdate = this::updatePreviewAndDialogState, copyPost = this::copyPost, - syncPublishingFeatureConfig = syncPublishingFeatureConfig + syncPublishingFeatureUtils = syncPublishingFeatureUtils ) } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/SyncPublishingFeatureUtils.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/SyncPublishingFeatureUtils.kt new file mode 100644 index 000000000000..caf4f1ef0fca --- /dev/null +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/SyncPublishingFeatureUtils.kt @@ -0,0 +1,32 @@ +package org.wordpress.android.ui.posts + +import org.wordpress.android.fluxc.store.PostStore +import org.wordpress.android.util.BuildConfigWrapper +import org.wordpress.android.util.config.SyncPublishingFeatureConfig +import javax.inject.Inject + +class SyncPublishingFeatureUtils @Inject constructor( + private val syncPublishingFeatureConfig: SyncPublishingFeatureConfig, + private val buildConfigWrapper: BuildConfigWrapper, +) { + private fun isSyncPublishingEnabled(): Boolean { + return buildConfigWrapper.isJetpackApp && + syncPublishingFeatureConfig.isEnabled() + } + + /** + * This helper function aids in post-conflict resolution. When attempting to edit a post, + * sending the "if_not_modified_since" to the backend will trigger a 409 error if a newer version + * has already been uploaded from another device. This functionality should be encapsulated + * by the SYNC_PUBLISHING feature flag. The function is used to generate the final RemotePostPayload + * that is sent to the backend through PostActionBuilder.newPushPostAction(). By setting the + * isConflictResolution = true, "if_not_modified_since" is not sent to server and the post overwrites + * the remote version. + */ + fun getRemotePostPayloadForPush(payload: PostStore.RemotePostPayload): PostStore.RemotePostPayload { + if (isSyncPublishingEnabled().not()) { + payload.isConflictResolution = true + } + return payload + } +} diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java index d7bd93a86ecc..2448042982a2 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadHandler.java @@ -34,6 +34,7 @@ import org.wordpress.android.fluxc.store.PostStore.RemotePostPayload; import org.wordpress.android.fluxc.store.SiteStore; import org.wordpress.android.ui.posts.PostUtils; +import org.wordpress.android.ui.posts.SyncPublishingFeatureUtils; import org.wordpress.android.ui.prefs.AppPrefs; import org.wordpress.android.ui.uploads.AutoSavePostIfNotDraftResult.FetchPostStatusFailed; import org.wordpress.android.ui.uploads.AutoSavePostIfNotDraftResult.PostAutoSaveFailed; @@ -48,7 +49,6 @@ import org.wordpress.android.util.SiteUtils; import org.wordpress.android.util.SqlUtils; import org.wordpress.android.util.analytics.AnalyticsUtils; -import org.wordpress.android.util.config.SyncPublishingFeatureConfig; import org.wordpress.android.util.helpers.MediaFile; import java.io.File; @@ -84,7 +84,7 @@ public class PostUploadHandler implements UploadHandler, OnAutoSavePo @Inject UploadActionUseCase mUploadActionUseCase; @Inject AutoSavePostIfNotDraftUseCase mAutoSavePostIfNotDraftUseCase; @Inject PostMediaHandler mPostMediaHandler; - @Inject SyncPublishingFeatureConfig mSyncPublishingFeatureConfig; + @Inject SyncPublishingFeatureUtils mSyncPublishingFeatureUtils; PostUploadHandler(PostUploadNotifier postUploadNotifier) { ((WordPress) WordPress.getContext().getApplicationContext()).component().inject(this); @@ -289,7 +289,7 @@ protected UploadPostTaskResult doInBackground(PostModel... posts) { AppLog.d(T.POSTS, "PostUploadHandler - UPLOAD. Post: " + mPost.getTitle()); mDispatcher.dispatch( PostActionBuilder.newPushPostAction( - mSyncPublishingFeatureConfig.getRemotePostPayloadForPush(payload) + mSyncPublishingFeatureUtils.getRemotePostPayloadForPush(payload) ) ); break; @@ -297,7 +297,7 @@ protected UploadPostTaskResult doInBackground(PostModel... posts) { mPost.setStatus(PostStatus.DRAFT.toString()); AppLog.d(T.POSTS, "PostUploadHandler - UPLOAD_AS_DRAFT. Post: " + mPost.getTitle()); mDispatcher.dispatch(PostActionBuilder.newPushPostAction( - mSyncPublishingFeatureConfig.getRemotePostPayloadForPush(payload) + mSyncPublishingFeatureUtils.getRemotePostPayloadForPush(payload) )); break; case REMOTE_AUTO_SAVE: @@ -646,7 +646,7 @@ public void handleAutoSavePostIfNotDraftResult(@NonNull AutoSavePostIfNotDraftRe post.setStatus(PostStatus.DRAFT.toString()); SiteModel site = mSiteStore.getSiteByLocalId(post.getLocalSiteId()); mDispatcher.dispatch(PostActionBuilder.newPushPostAction( - mSyncPublishingFeatureConfig.getRemotePostPayloadForPush(new RemotePostPayload(post, site)) + mSyncPublishingFeatureUtils.getRemotePostPayloadForPush(new RemotePostPayload(post, site)) )); } else { throw new IllegalStateException("All AutoSavePostIfNotDraftResult types must be handled"); diff --git a/WordPress/src/main/java/org/wordpress/android/util/config/SyncPublishingFeatureConfig.kt b/WordPress/src/main/java/org/wordpress/android/util/config/SyncPublishingFeatureConfig.kt index cca640b95b71..e1a4580e3b20 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/config/SyncPublishingFeatureConfig.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/config/SyncPublishingFeatureConfig.kt @@ -2,7 +2,6 @@ package org.wordpress.android.util.config import org.wordpress.android.BuildConfig import org.wordpress.android.annotation.Feature -import org.wordpress.android.fluxc.store.PostStore.RemotePostPayload import javax.inject.Inject private const val SYNC_PUBLISHING_FEATURE_REMOTE_FIELD = "sync_publishing" @@ -14,20 +13,4 @@ class SyncPublishingFeatureConfig @Inject constructor( appConfig, BuildConfig.SYNC_PUBLISHING, SYNC_PUBLISHING_FEATURE_REMOTE_FIELD -) { - /** - * This helper function aids in post-conflict resolution. When attempting to edit a post, - * sending the "if_not_modified_since" to the backend will trigger a 409 error if a newer version - * has already been uploaded from another device. This functionality should be encapsulated - * by the SYNC_PUBLISHING feature flag. The function is used to generate the final RemotePostPayload - * that is sent to the backend through PostActionBuilder.newPushPostAction(). By setting the - * isConflictResolution = true, "if_not_modified_since" is not sent to server and the post overwrites - * the remote version. - */ - fun getRemotePostPayloadForPush(payload: RemotePostPayload): RemotePostPayload { - if (this@SyncPublishingFeatureConfig.isEnabled().not()) { - payload.isConflictResolution = true - } - return payload - } -} +) From 3ded8f022f5a41c4d1652704ea02d1515fa16ab9 Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Thu, 4 Apr 2024 14:14:18 +0300 Subject: [PATCH 20/28] Fixes: checkstyle and detekt issues --- .../java/org/wordpress/android/ui/posts/PostActionHandler.kt | 1 - .../org/wordpress/android/ui/posts/PostListMainViewModel.kt | 1 - .../wordpress/android/ui/posts/SyncPublishingFeatureUtils.kt | 4 ++-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostActionHandler.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostActionHandler.kt index 9c37c4b413fc..132e2af293de 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostActionHandler.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostActionHandler.kt @@ -30,7 +30,6 @@ import org.wordpress.android.ui.uploads.UploadService import org.wordpress.android.ui.uploads.UploadUtils import org.wordpress.android.ui.utils.UiString.UiStringRes import org.wordpress.android.util.ToastUtils.Duration -import org.wordpress.android.util.config.SyncPublishingFeatureConfig import org.wordpress.android.viewmodel.helpers.ToastMessageHolder import org.wordpress.android.widgets.PostListButtonType import org.wordpress.android.widgets.PostListButtonType.BUTTON_CANCEL_PENDING_AUTO_UPLOAD diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt index c47cc9bcd1cb..c27bf9524922 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewModel.kt @@ -47,7 +47,6 @@ import org.wordpress.android.util.NetworkUtilsWrapper import org.wordpress.android.util.ToastUtils.Duration import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper import org.wordpress.android.util.analytics.AnalyticsUtils -import org.wordpress.android.util.config.SyncPublishingFeatureConfig import org.wordpress.android.viewmodel.Event import org.wordpress.android.viewmodel.SingleLiveEvent import org.wordpress.android.viewmodel.helpers.DialogHolder diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/SyncPublishingFeatureUtils.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/SyncPublishingFeatureUtils.kt index caf4f1ef0fca..c777631f37de 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/SyncPublishingFeatureUtils.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/SyncPublishingFeatureUtils.kt @@ -1,6 +1,6 @@ package org.wordpress.android.ui.posts -import org.wordpress.android.fluxc.store.PostStore +import org.wordpress.android.fluxc.store.PostStore.RemotePostPayload import org.wordpress.android.util.BuildConfigWrapper import org.wordpress.android.util.config.SyncPublishingFeatureConfig import javax.inject.Inject @@ -23,7 +23,7 @@ class SyncPublishingFeatureUtils @Inject constructor( * isConflictResolution = true, "if_not_modified_since" is not sent to server and the post overwrites * the remote version. */ - fun getRemotePostPayloadForPush(payload: PostStore.RemotePostPayload): PostStore.RemotePostPayload { + fun getRemotePostPayloadForPush(payload: RemotePostPayload): RemotePostPayload { if (isSyncPublishingEnabled().not()) { payload.isConflictResolution = true } From 9e1930e752e04839e7e63321c5e5b64a04879423 Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Thu, 4 Apr 2024 16:02:53 +0300 Subject: [PATCH 21/28] Fixes: PostConflictResolver UI issue --- .../java/org/wordpress/android/ui/posts/PostConflictResolver.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt index ab35663c3f54..5e3109b2e18e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt @@ -45,7 +45,6 @@ class PostConflictResolver( post.setIsLocallyChanged(false) post.setAutoSaveExcerpt(null) post.setAutoSaveRevisionId(0) - postStore.removeLocalRevision(post) dispatcher.dispatch(PostActionBuilder.newFetchPostAction(RemotePostPayload(post, site))) showToast.invoke(ToastMessageHolder(R.string.toast_conflict_updating_post, Duration.SHORT)) } @@ -88,6 +87,7 @@ class PostConflictResolver( originalPostId = null // Conflicted post has been successfully updated with its remote version uploadStore.clearUploadErrorForPost(updatedPost) + postStore.removeLocalRevision(updatedPost) if (!PostUtils.isPostInConflictWithRemote(updatedPost)) { conflictedPostUpdatedWithRemoteVersion() } From 1f7b70285c68047d77635727026d3a22f981fa39 Mon Sep 17 00:00:00 2001 From: Annmarie Ziegler Date: Thu, 4 Apr 2024 09:30:37 -0400 Subject: [PATCH 22/28] Update failing tests to account for syncPublishingFeatureUtils --- .../org/wordpress/android/ui/posts/PostConflictResolverTest.kt | 1 + .../android/ui/posts/PostListMainViewModelCopyPostTest.kt | 3 ++- .../wordpress/android/ui/posts/PostListMainViewModelTest.kt | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/WordPress/src/test/java/org/wordpress/android/ui/posts/PostConflictResolverTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/posts/PostConflictResolverTest.kt index d11c70e090f0..070d6938d114 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/posts/PostConflictResolverTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/posts/PostConflictResolverTest.kt @@ -145,6 +145,7 @@ class PostConflictResolverTest : BaseUnitTest() { verify(uploadStore).clearUploadErrorForPost(updatedPost) verify(showSnackbar).invoke(expectedSnackbarMessage) + verify(postStore).removeLocalRevision(updatedPost) } } diff --git a/WordPress/src/test/java/org/wordpress/android/ui/posts/PostListMainViewModelCopyPostTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/posts/PostListMainViewModelCopyPostTest.kt index 4dfb685d0a7e..fa36266f0b57 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/posts/PostListMainViewModelCopyPostTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/posts/PostListMainViewModelCopyPostTest.kt @@ -73,7 +73,8 @@ class PostListMainViewModelCopyPostTest : BaseUnitTest() { postListEventListenerFactory = mock(), uploadStarter = mock(), uploadActionUseCase = mock(), - savePostToDbUseCase = mock() + savePostToDbUseCase = mock(), + syncPublishingFeatureUtils = mock() ) viewModel.postListAction.observeForever(onPostListActionObserver) diff --git a/WordPress/src/test/java/org/wordpress/android/ui/posts/PostListMainViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/posts/PostListMainViewModelTest.kt index 57bbb125e1b5..e3750f0e56d1 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/posts/PostListMainViewModelTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/posts/PostListMainViewModelTest.kt @@ -66,7 +66,8 @@ class PostListMainViewModelTest : BaseUnitTest() { postListEventListenerFactory = mock(), uploadStarter = uploadStarter, uploadActionUseCase = mock(), - savePostToDbUseCase = savePostToDbUseCase + savePostToDbUseCase = savePostToDbUseCase, + syncPublishingFeatureUtils = mock() ) } From 3dc28bf93d29c29766f6a867b9e8092dd76d5c94 Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Thu, 4 Apr 2024 17:52:18 +0300 Subject: [PATCH 23/28] Fixes: checkstyle issues --- .../org/wordpress/android/ui/posts/PostConflictResolverTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/test/java/org/wordpress/android/ui/posts/PostConflictResolverTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/posts/PostConflictResolverTest.kt index 070d6938d114..cccea5aaf8f5 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/posts/PostConflictResolverTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/posts/PostConflictResolverTest.kt @@ -22,7 +22,6 @@ import org.wordpress.android.ui.utils.UiString import org.wordpress.android.viewmodel.helpers.ToastMessageHolder import kotlin.test.Test import org.wordpress.android.R -import org.wordpress.android.util.ToastUtils @Suppress("UNCHECKED_CAST") @ExperimentalCoroutinesApi @@ -97,6 +96,7 @@ class PostConflictResolverTest : BaseUnitTest() { assertTrue(result) } + @Suppress("MaxLineLength") @Test fun `given upload store with no unhandled conflict, when does post have unhandled conflict is invoked, then false`() { val post = PostModel() From e76d6d647e9d3d1a9a5aa1180d49ad2c19f62ed4 Mon Sep 17 00:00:00 2001 From: Annmarie Ziegler Date: Thu, 4 Apr 2024 11:46:14 -0400 Subject: [PATCH 24/28] Add unit tests for SyncPublishingFeatureUtils --- .../posts/SyncPublishingFeatureUtilsTest.kt | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 WordPress/src/test/java/org/wordpress/android/ui/posts/SyncPublishingFeatureUtilsTest.kt diff --git a/WordPress/src/test/java/org/wordpress/android/ui/posts/SyncPublishingFeatureUtilsTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/posts/SyncPublishingFeatureUtilsTest.kt new file mode 100644 index 000000000000..56f249cbaa5e --- /dev/null +++ b/WordPress/src/test/java/org/wordpress/android/ui/posts/SyncPublishingFeatureUtilsTest.kt @@ -0,0 +1,50 @@ +package org.wordpress.android.ui.posts + +import kotlinx.coroutines.ExperimentalCoroutinesApi +import org.assertj.core.api.Assertions.assertThat +import org.junit.Before +import org.junit.Test +import org.mockito.Mock +import org.mockito.kotlin.mock +import org.mockito.kotlin.whenever +import org.wordpress.android.BaseUnitTest +import org.wordpress.android.fluxc.model.PostModel +import org.wordpress.android.fluxc.model.SiteModel +import org.wordpress.android.fluxc.store.PostStore.RemotePostPayload +import org.wordpress.android.util.config.SyncPublishingFeatureConfig + +@ExperimentalCoroutinesApi +class SyncPublishingFeatureUtilsTest : BaseUnitTest() { + @Mock + lateinit var syncPublishingFeatureConfig: SyncPublishingFeatureConfig + + private val site: SiteModel = mock() + private val post: PostModel = mock() + + private lateinit var syncPublishingFeatureUtils: SyncPublishingFeatureUtils + + @Before + fun setUp() { + syncPublishingFeatureUtils = SyncPublishingFeatureUtils(syncPublishingFeatureConfig) + } + + @Test + fun `given feature is enabled, when request for payload, then shouldSkipConflictResolution to false`() { + whenever(syncPublishingFeatureConfig.isEnabled()).thenReturn(true) + val remotePostPayload = RemotePostPayload(post, site) + + val result = syncPublishingFeatureUtils.getRemotePostPayloadForPush(remotePostPayload) + + assertThat(result.shouldSkipConflictResolutionCheck).isFalse + } + + @Test + fun `given feature is disabled, when request for payload, then sets shouldSkipConflictResolution to true`() { + whenever(syncPublishingFeatureConfig.isEnabled()).thenReturn(false) + val remotePostPayload = RemotePostPayload(post, site) + + val result = syncPublishingFeatureUtils.getRemotePostPayloadForPush(remotePostPayload) + + assertThat(result.shouldSkipConflictResolutionCheck).isTrue + } +} From 80e9497fd3a8b5f512d9f0fc4fe68b835d3283aa Mon Sep 17 00:00:00 2001 From: Annmarie Ziegler Date: Thu, 4 Apr 2024 11:47:46 -0400 Subject: [PATCH 25/28] Remove check for isJetpackApp and applied name change from isConflictionResolution to shouldSkipConflictResolutionCheck --- .../android/ui/posts/SyncPublishingFeatureUtils.kt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/SyncPublishingFeatureUtils.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/SyncPublishingFeatureUtils.kt index c777631f37de..cbc5ef6564e3 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/SyncPublishingFeatureUtils.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/SyncPublishingFeatureUtils.kt @@ -1,17 +1,14 @@ package org.wordpress.android.ui.posts import org.wordpress.android.fluxc.store.PostStore.RemotePostPayload -import org.wordpress.android.util.BuildConfigWrapper import org.wordpress.android.util.config.SyncPublishingFeatureConfig import javax.inject.Inject class SyncPublishingFeatureUtils @Inject constructor( - private val syncPublishingFeatureConfig: SyncPublishingFeatureConfig, - private val buildConfigWrapper: BuildConfigWrapper, + private val syncPublishingFeatureConfig: SyncPublishingFeatureConfig ) { private fun isSyncPublishingEnabled(): Boolean { - return buildConfigWrapper.isJetpackApp && - syncPublishingFeatureConfig.isEnabled() + return syncPublishingFeatureConfig.isEnabled() } /** @@ -20,12 +17,12 @@ class SyncPublishingFeatureUtils @Inject constructor( * has already been uploaded from another device. This functionality should be encapsulated * by the SYNC_PUBLISHING feature flag. The function is used to generate the final RemotePostPayload * that is sent to the backend through PostActionBuilder.newPushPostAction(). By setting the - * isConflictResolution = true, "if_not_modified_since" is not sent to server and the post overwrites + * shouldSkipConflictResolutionCheck = true, "if_not_modified_since" is not sent to server and the post overwrites * the remote version. */ fun getRemotePostPayloadForPush(payload: RemotePostPayload): RemotePostPayload { if (isSyncPublishingEnabled().not()) { - payload.isConflictResolution = true + payload.shouldSkipConflictResolutionCheck = true } return payload } From decfcb79ed62ef60124e39aea2699ae55d43077c Mon Sep 17 00:00:00 2001 From: Annmarie Ziegler Date: Thu, 4 Apr 2024 11:48:18 -0400 Subject: [PATCH 26/28] Apply name change from isConflictionResolution to shouldSkipConflictResolutionCheck --- .../java/org/wordpress/android/ui/posts/PostConflictResolver.kt | 2 +- .../org/wordpress/android/ui/posts/PostConflictResolverTest.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt index 5e3109b2e18e..835faac2b491 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostConflictResolver.kt @@ -69,7 +69,7 @@ class PostConflictResolver( PostUtils.trackSavePostAnalytics(post, site) val remotePostPayload = RemotePostPayload(post, site) - remotePostPayload.isConflictResolution = true + remotePostPayload.shouldSkipConflictResolutionCheck = true dispatcher.dispatch(PostActionBuilder.newPushPostAction(remotePostPayload)) } diff --git a/WordPress/src/test/java/org/wordpress/android/ui/posts/PostConflictResolverTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/posts/PostConflictResolverTest.kt index cccea5aaf8f5..6039061ceb3f 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/posts/PostConflictResolverTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/posts/PostConflictResolverTest.kt @@ -98,7 +98,7 @@ class PostConflictResolverTest : BaseUnitTest() { @Suppress("MaxLineLength") @Test - fun `given upload store with no unhandled conflict, when does post have unhandled conflict is invoked, then false`() { + fun `given upload store with no unhandled conflict, when post have unhandled conflict is invoked, then false`() { val post = PostModel() whenever(uploadStore.getUploadErrorForPost(post)).thenReturn(null) From 614fc1d1223ed7665991e326c6ce98661296f904 Mon Sep 17 00:00:00 2001 From: Annmarie Ziegler Date: Thu, 4 Apr 2024 12:32:54 -0400 Subject: [PATCH 27/28] Update fluxC hash --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 3ae1461f4727..fd2103aa0cee 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ ext { automatticTracksVersion = '4.0.2' gutenbergMobileVersion = 'v1.116.0' wordPressAztecVersion = 'v2.1.1' - wordPressFluxCVersion = '2982-581a6f927307f470bf13c68f74270666c58de004' + wordPressFluxCVersion = '2982-c003406300b8e1710344bfbb3d01720b86d72e72' wordPressLoginVersion = '1.14.1' wordPressPersistentEditTextVersion = '1.0.2' wordPressUtilsVersion = '3.14.0' From edc512e0ebbcdad5eba5f3d941e8438ab9aa0c75 Mon Sep 17 00:00:00 2001 From: Annmarie Ziegler Date: Thu, 4 Apr 2024 15:00:52 -0400 Subject: [PATCH 28/28] update FluxC hash --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index fd2103aa0cee..46baee6f28d8 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ ext { automatticTracksVersion = '4.0.2' gutenbergMobileVersion = 'v1.116.0' wordPressAztecVersion = 'v2.1.1' - wordPressFluxCVersion = '2982-c003406300b8e1710344bfbb3d01720b86d72e72' + wordPressFluxCVersion = 'trunk-f154a1ace883ee3e0f4b1308a76c9316109b6b03' wordPressLoginVersion = '1.14.1' wordPressPersistentEditTextVersion = '1.0.2' wordPressUtilsVersion = '3.14.0'