Skip to content

Instantly share code, notes, and snippets.

@kean
Last active June 22, 2025 00:33
Show Gist options
  • Select an option

  • Save kean/e88f6de0bd4f234b55fa76cfb345b137 to your computer and use it in GitHub Desktop.

Select an option

Save kean/e88f6de0bd4f234b55fa76cfb345b137 to your computer and use it in GitHub Desktop.
Prompt: How does the app handle conflicts?
How does the app handles data conflicts when it syncs changes to the post to the server?
⏺ I'll help you understand how the WordPress iOS app handles data conflicts when syncing post changes to the server.
Let me search for the relevant code.
⏺ Task(Search for post sync conflict handling)
⎿  Done (20 tool uses · 71.8k tokens · 2m 57.5s)
⏺ The WordPress iOS app handles data conflicts during post synchronization through a sophisticated multi-layered
approach:
Key Components:
1. PostCoordinator (WordPress/Classes/Services/PostCoordinator.swift) - Manages sync operations with automatic retry
logic using exponential backoff (15-120 seconds)
2. PostRepository (WordPress/Classes/Services/PostRepository.swift) - Implements optimistic locking using
ifNotModifiedSince headers to detect when server content has changed
3. Conflict Resolution UI (WordPress/Classes/ViewRelated/Post/Views/ResolveConflictView.swift) - Presents users with
a choice between "Current device" and "Another device" versions when conflicts occur
Conflict Detection:
- Compares dateModified timestamps between local and server versions
- Server returns HTTP 412 (Precondition Failed) when content has been modified elsewhere
- Detects false positives and retries without preconditions when appropriate
Resolution Strategy:
- Creates local revisions while offline that sync when reconnected
- Only sends changed fields (delta updates) to minimize conflicts
- Shows visual comparison with modification dates for both versions
- Users can choose to keep local changes or accept server version
The system supports collaborative editing, handles network failures gracefully, and ensures data consistency through
revision tracking and smart sync mechanisms.
> It does not support collaborative editing.
⏺ You're correct - I misspoke. The WordPress iOS app does not support collaborative editing.
The conflict resolution system is designed to handle situations where the same post is edited from different devices
(like editing on both your phone and computer), but it's not real-time collaborative editing. When a conflict is
detected:
1. PostRepository (WordPress/Classes/Services/PostRepository.swift) detects that the server version has been
modified since the last sync using timestamp comparison
2. ResolveConflictView (WordPress/Classes/ViewRelated/Post/Views/ResolveConflictView.swift) presents a choice to the
user: keep the current device's version or use the version from another device
3. The user must choose one version or the other - there's no merging of changes or real-time collaboration
This is a "last write wins" approach with user intervention when conflicts are detected, not collaborative editing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment