Hi all! I have a fairly large application that has been running for more than half a year in our company.
BUT there is a big problem!
Sometimes when you click on a button in an application that should create a document in a Firebase collection, the same document is created twice! Sometimes even with different parameters. This happens several times a month, which is very annoying.
Here are some scenarios when this happens:
1. In the morning, employees come to work and check in at what point they are working today. It is also recorded what time they arrived at work.
In the application, they press a button and a document is created with the time, place, name, whether they are late or not, geolocation, etc.
At this moment, sometimes, for some reason, two documents are created. It was as if two identical people, clones, came to work at the same moment. Moreover, in one document the delay will be recorded, for example, in the second it will not be recorded
2. In the morning, employees open their shift, cash register, in the application.
Sometimes two copies open at once, two identical studios. That is, two documents are created.
3, The employee pays the client and closes the check.
At this moment the client card is closed. The client's check amount is added to the general cash register (Here is the action of adding to an already created Firebase document) and the page for closing the check is closed.
But sometimes the amount is added twice, just like in the previous examples. Only now two documents are not created, but two additions are made.
For example it should be like this:
150 (cash for the day) + 100 (amount of the new client’s check) = 250 (total total with the new client)
And it turns out like this:
150 + 100 + 100 = 350
Does anyone know what the problem is and how to fix it?
Accidental sharp, quick, double pressing of the button is excluded.
Perhaps there is a problem with the Internet at this moment? But how can this be avoided in this case?