erquhart
erquhart2y ago

Optimistically deleting an optimistically inserted object

If I optimistically add an item to a list, and then delete before the operation has completed, a mutation will be attempted at some point with the fake id from the optimistic item, which fails. The result for the user is basically a flicker and harmless failure, but I'm curious if there's an approach I'm not considering here. For now my solution is to block removal until insertion is complete (just checking if the id is a uuid for this).
2 Replies
ian
ian2y ago
When you write optimistic data, you can include extra fields, identifying it at as an ephemeral object, then grey out the delete button until it’s a real ID? Or have the ID format be your signal- like “pending“+uuid It sounds like that’s your current approach, after another read. Another idea is to delete it by identifying it another way, but then you risk IDOR vulnerabilities. We’ve discussed supporting optimistic id generation, client-side, but don’t have concrete plans for it right now.
erquhart
erquhartOP2y ago
Yeah the more I think about it, just waiting makes sense

Did you find this page helpful?