I have a calendar driven by data from firebase. When a user makes an edit, by moving or resizing a task, it will quickly move back to its original position, then the database will update the client, and the new data will be shown on the page.
Here is a simple diagram to explain:
A - User moves task in calendar UI
↓
B - UI flicks back to its previous position
↓
C - Data is sent to Cloud Firestore
↓
D - Updated data is returned to the client via a realtime listener
↓
E - UI is updated
The delay between points A and E can be as small as 50ms, but in times as long as 1000ms.
Is there any way, after a user makes a change, to store temporary data in the user's browser that reflects the updates while the data in firestore is being updated? When the realtime listener fires, it will reset the temporary data and all will be up to date.
This is my current code to listen for changes and update the projects
variable:
const [projects, loadingProjects, errorProjects] = useCollection(
organisationID && firebase.firestore().collection('organisations').doc(organisationID).collection("projects"),
{
snapshotListenOptions: { includeMetadataChanges: true },
}
);
How would I go about implementing a system like this in React?