May 2022: update diaries across devices with confidence
Here at Sleepvue, we care a lot about user experience. We want to make keeping a sleep diary as easy as possible. One problem I've had is related to updating sleep logs works across devices.
Maybe you have Sleepvue open on your laptop and you then want to add a tag or note from your phone.
Historically, whichever update happened last wins and overwrote any changes that the UI didn't know about. We now use a programming technique called optimistic concurrency to prevent this. Let me explain.
Imagine you are updating the same sleep log on your laptop and on your phone. You want to add some new notes, which start like this:

On your laptop, you hastily add some more notes "Hello world, how do you do?". On your phone, you'll still see Hello world, but now if you make a change, you will get a warning banner that the sleep log was modified and that you need to copy your changes, refresh the page, and apply them:

Now you can be less worried about accidentally overwriting your own changes!