Sync data between Clients (Can change data offline) and Server with Firestore?

Viewed 29

I'm trying to build an offline-first application that stores encrypted data in localStorage (the value is encrypted and key is named as data).

The problem is that a client can login on multiple devices and get their encrypted text synced. I want to create a solution, where I can sync data between multiple devices, so that the text always remains with latest changes on all devices.

I thought of using timestamps along with the encrypted text but this is proving quite challenging as the timestamp is depends on the machine and any user could change their system time knowingly/unknowingly to overwrite the data in firestore.

How can I make sure that the clients can edit their data offline but only the latest changes are kept in the database and all clients when online.

0 Answers
Related