StarlordS
Convex Community10mo ago
1 reply
Starlord

Optimistic Update conflict

I'm working on a 'favorites' feature for products, where you can like or unlike an item. When you like something, it shows up as liked right away on your screen because I save it locally. If you unlike it, it disappears from your local favorites immediately.

The tricky part is when you quickly like and then unlike an item. Your screen shows it as unliked, which is correct. But, the 'like' action is still being processed by the server. If the server confirms the 'like' after you've already unliked it, the item flashes as 'liked' for a moment before going back to 'unliked'. It's a bit of a visual glitch.

Is there a good way to stop this from happening and make sure the screen always shows what you actually last did, even if the server is a bit slow to catch up?

As far I can see need client side convex package adjustments to make this happen. This feature is needed by a lot of production ready apps like Instagram for example.
Was this page helpful?