Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offline mode: Post conflict resolution overlay #20607

Merged
merged 36 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e5de678
Add wrapper around DateUtils for testability
zwarm Apr 7, 2024
71ed026
Initial versions of fragment and vm for PostResolutionOverlay
zwarm Apr 7, 2024
434d94d
Set up di modules for post resolution overlay
zwarm Apr 7, 2024
f31e6c7
Add wrapper around timestampFromIso8601Millis
zwarm Apr 7, 2024
a2bf427
Add base strings for post resolution overlay
zwarm Apr 7, 2024
f8339fe
WIP - Show the post resolution overlay instead of the dialog.
zwarm Apr 7, 2024
fda28f0
Change save to confirm and use string resource for both buttons
zwarm Apr 8, 2024
88786ae
Add a listener interface for post resolution
zwarm Apr 8, 2024
27dc8a3
Hooked in the initial version of the PostResolutionOverlayListener
zwarm Apr 8, 2024
c205244
Hook in the initial version of the PostResolutionOverlayListener
zwarm Apr 8, 2024
98cb540
WIP - Added self comments and todos
zwarm Apr 8, 2024
308bec0
Rename: PostConflictResolutionType to PostResolutionType
zwarm Apr 8, 2024
19e5e87
Reduce the callbacks to a single function and handle downstream
zwarm Apr 8, 2024
5220ce3
Hook the dismiss actions (cancel, dismiss, and close) and the prelimi…
zwarm Apr 8, 2024
68b3928
Make fun public so enabled can be accessed
zwarm Apr 10, 2024
6619c9e
Pass the value of isSyncPublishingEnabled flag over to the dialogHelper
zwarm Apr 10, 2024
8abc56f
Add string resources for autosave overlay
zwarm Apr 10, 2024
d943074
Rename the listener function
zwarm Apr 10, 2024
64a8ea3
Updates to reflect name changes and signature types
zwarm Apr 10, 2024
d41b26d
Adjsut for name changes and handle onPostResolutionConfirmed
zwarm Apr 10, 2024
08db006
Adjust for renaming and implement autosave sync logic
zwarm Apr 10, 2024
253306d
Adjust to name changes. Handle the confirm action clicks for post res…
zwarm Apr 10, 2024
b2d8032
Address detekt, lint, and checkstyle issue. Remove log lines
zwarm Apr 10, 2024
a4e744d
Refactor: move composables out of fragment
zwarm Apr 10, 2024
c16d387
Refactor: move UiState to its own file
zwarm Apr 10, 2024
e0bfc66
Add unit tests for PostResolutionOverlayViewModel and minor adjustmen…
zwarm Apr 10, 2024
a69336c
refactor: rename SyncPublishingFeatureConfig
pantstamp Apr 11, 2024
f7dd712
Refactor: Allow PostResolutionListener to be null for detach purposes
zwarm Apr 11, 2024
37597dc
Remove todo
zwarm Apr 11, 2024
6cd3ad4
Check for fragment before creating
zwarm Apr 11, 2024
83e8880
Annotate with JvmStatic
zwarm Apr 11, 2024
bb4997b
Do not dismiss the dialog on an super dismiss to support orientation …
zwarm Apr 11, 2024
ee422b4
Add post resolution tracking events
zwarm Apr 11, 2024
e71f620
Add tracker for post resolution overlay
zwarm Apr 11, 2024
8089791
Implement tracking for post resolution conflict overlay
zwarm Apr 11, 2024
0f4f175
Fixes: PostListMainViewModel multiple starts
pantstamp Apr 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
import org.wordpress.android.ui.posts.PostDatePickerDialogFragment;
import org.wordpress.android.ui.posts.PostListFragment;
import org.wordpress.android.ui.posts.PostNotificationScheduleTimeDialogFragment;
import org.wordpress.android.ui.posts.PostResolutionOverlayFragment;
import org.wordpress.android.ui.posts.PostSettingsListDialogFragment;
import org.wordpress.android.ui.posts.PostSettingsTagsFragment;
import org.wordpress.android.ui.posts.PostTimePickerDialogFragment;
Expand Down Expand Up @@ -555,4 +556,6 @@ public interface AppComponent {
void inject(WeekWidgetBlockListProviderFactory object);

void inject(WPMainNavigationView object);

void inject(PostResolutionOverlayFragment object);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.wordpress.android.ui.posts.EditorBloggingPromptsViewModel;
import org.wordpress.android.ui.posts.EditorJetpackSocialViewModel;
import org.wordpress.android.ui.posts.PostListMainViewModel;
import org.wordpress.android.ui.posts.PostResolutionOverlayViewModel;
import org.wordpress.android.ui.posts.editor.StorePostViewModel;
import org.wordpress.android.ui.posts.prepublishing.PrepublishingViewModel;
import org.wordpress.android.ui.posts.prepublishing.categories.PrepublishingCategoriesViewModel;
Expand Down Expand Up @@ -539,4 +540,9 @@ abstract class ViewModelModule {
@IntoMap
@ViewModelKey(EditorJetpackSocialViewModel.class)
abstract ViewModel editorJetpackSocialViewModel(EditorJetpackSocialViewModel viewModel);

@Binds
@IntoMap
@ViewModelKey(PostResolutionOverlayViewModel.class)
abstract ViewModel postResolutionOverlayViewModel(PostResolutionOverlayViewModel viewModel);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.wordpress.android.ui.posts

import android.util.Log
import org.wordpress.android.R
import org.wordpress.android.analytics.AnalyticsTracker.Stat.UNPUBLISHED_REVISION_DIALOG_LOAD_LOCAL_VERSION_CLICKED
import org.wordpress.android.analytics.AnalyticsTracker.Stat.UNPUBLISHED_REVISION_DIALOG_LOAD_UNPUBLISHED_VERSION_CLICKED
Expand Down Expand Up @@ -28,7 +29,8 @@ private const val POST_TYPE = "post_type"
class PostListDialogHelper(
private val showDialog: (DialogHolder) -> Unit,
private val checkNetworkConnection: () -> Boolean,
private val analyticsTracker: AnalyticsTrackerWrapper
private val analyticsTracker: AnalyticsTrackerWrapper,
private val showConflictResolutionOverlay: ((PostModel) -> Unit)? = null
zwarm marked this conversation as resolved.
Show resolved Hide resolved
) {
// Since we are using DialogFragments we need to hold onto which post will be published or trashed / resolved
private var localPostIdForDeleteDialog: Int? = null
Expand Down Expand Up @@ -114,6 +116,7 @@ class PostListDialogHelper(
showDialog.invoke(dialogHolder)
}

// todo: THis is the one ... maybe the dialog holder can be passed instead
fun showConflictedPostResolutionDialog(post: PostModel) {
val dialogHolder = DialogHolder(
tag = CONFIRM_ON_CONFLICT_LOAD_REMOTE_POST_DIALOG_TAG,
Expand All @@ -123,7 +126,10 @@ class PostListDialogHelper(
negativeButton = UiStringRes(R.string.dialog_confirm_load_remote_post_discard_web)
)
localPostIdForConflictResolutionDialog = post.id
showDialog.invoke(dialogHolder)
Log.i(javaClass.simpleName, "***=> show the improved dialog ${dialogHolder.javaClass.simpleName}")
showConflictResolutionOverlay?.invoke(post)
// todo: annmarie - show the improved
// showDialog.invoke(dialogHolder)
}

fun showAutoSaveRevisionDialog(post: PostModel) {
Expand Down Expand Up @@ -172,6 +178,7 @@ class PostListDialogHelper(
localPostIdForScheduledPostSyncDialog = null
publishPost(it)
}
// todo: annmarie
CONFIRM_ON_CONFLICT_LOAD_REMOTE_POST_DIALOG_TAG -> localPostIdForConflictResolutionDialog?.let {
localPostIdForConflictResolutionDialog = null
// here load version from remote
Expand All @@ -189,6 +196,7 @@ class PostListDialogHelper(
localPostIdForMoveTrashedPostToDraftDialog = null
moveTrashedPostToDraft(it)
}
// todo: annmarie
CONFIRM_ON_AUTOSAVE_REVISION_DIALOG_TAG -> localPostIdForAutosaveRevisionResolutionDialog?.let {
// open the editor with the restored auto save
localPostIdForAutosaveRevisionResolutionDialog = null
Expand Down Expand Up @@ -217,9 +225,11 @@ class PostListDialogHelper(
CONFIRM_SYNC_SCHEDULED_POST_DIALOG_TAG -> localPostIdForScheduledPostSyncDialog = null
CONFIRM_TRASH_POST_WITH_LOCAL_CHANGES_DIALOG_TAG -> localPostIdForTrashPostWithLocalChangesDialog = null
CONFIRM_TRASH_POST_WITH_UNSAVED_CHANGES_DIALOG_TAG -> localPostIdForTrashPostWithUnsavedChangesDialog = null
// todo: annmarie
CONFIRM_ON_CONFLICT_LOAD_REMOTE_POST_DIALOG_TAG -> localPostIdForConflictResolutionDialog?.let {
updateConflictedPostWithLocalVersion(it)
}
// todo: annmarie
CONFIRM_ON_AUTOSAVE_REVISION_DIALOG_TAG -> localPostIdForAutosaveRevisionResolutionDialog?.let {
// open the editor with the local post (don't use the auto save version)
editLocalPost(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.wordpress.android.ui.posts

import android.annotation.SuppressLint
import android.content.Intent
import android.util.Log
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LifecycleRegistry
Expand Down Expand Up @@ -128,6 +129,10 @@ class PostListMainViewModel @Inject constructor(
private val _dialogAction = SingleLiveEvent<DialogHolder>()
val dialogAction: LiveData<DialogHolder> = _dialogAction

// todo: annmarie a holder for the post resolution overlay
private val _conflictResolutionAction = SingleLiveEvent<PostModel>()
val conflictResolutionAction: LiveData<PostModel> = _conflictResolutionAction

private val _postUploadAction = SingleLiveEvent<PostUploadAction>()
val postUploadAction: LiveData<PostUploadAction> = _postUploadAction

Expand All @@ -150,6 +155,8 @@ class PostListMainViewModel @Inject constructor(
private val postListDialogHelper: PostListDialogHelper by lazy {
PostListDialogHelper(
showDialog = { _dialogAction.postValue(it) },
// todo: annmarie
showConflictResolutionOverlay = { _conflictResolutionAction.postValue(it) },
checkNetworkConnection = this::checkNetworkConnection,
analyticsTracker = analyticsTracker
)
Expand Down Expand Up @@ -478,6 +485,12 @@ class PostListMainViewModel @Inject constructor(
)
}

// Post Resolution Overlay Actions
fun onPostResolutionOverlayAction(action: PostResolutionOverlayAction) {
// todo: annmarie - implement this and remove the log
Log.i(javaClass.simpleName, "***=> onPostResolutionOverlayAction for ${action.name}")
}

private fun showPrepublishingBottomSheet(post: PostModel) {
currentBottomSheetPostId = LocalId(post.id)
editPostRepository.loadPostByLocalPostId(post.id)
Expand Down
Loading
Loading