-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20552 from wordpress-mobile/issue/20531-post-conf…
…lict Sync issues: Post conflict handling
- Loading branch information
Showing
18 changed files
with
371 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
WordPress/src/main/java/org/wordpress/android/ui/posts/SyncPublishingFeatureUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.wordpress.android.ui.posts | ||
|
||
import org.wordpress.android.fluxc.store.PostStore.RemotePostPayload | ||
import org.wordpress.android.util.config.SyncPublishingFeatureConfig | ||
import javax.inject.Inject | ||
|
||
class SyncPublishingFeatureUtils @Inject constructor( | ||
private val syncPublishingFeatureConfig: SyncPublishingFeatureConfig | ||
) { | ||
private fun isSyncPublishingEnabled(): Boolean { | ||
return 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 | ||
* 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.shouldSkipConflictResolutionCheck = true | ||
} | ||
return payload | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.