alexcorvi / apexo

A web/desktop application to manage your dental clinic practice.
https://apexo.app
MIT License
91 stars 48 forks source link

Documents keeps coming back after deleting them #125

Closed arinef closed 5 years ago

arinef commented 5 years ago

Describe the bug I noticed the documents that I delete will come back after I "Reload" the page or logged out then log in again

To Reproduce Steps to reproduce the behavior:

  1. Login to Apexo
  2. go to Patients and create a new one but type multiple characters so it takes multiple Rev
  3. Now delete that record
  4. press "F5" to reload or logout then login again

You will notice the same record will appear again (but the older rev), The record will be deleted from "CouchDB", but it will not from local "PouchDB"

Screenshots Before Delete delete doc

After Delete after delete

After Reload after refresh

Additional context Also, I felt some delay when I try to input very fast at the name field maybe it's due to syncing every character to remote DB, why don't we use a simple button to trigger the whole change one time like "save" button

alexcorvi commented 5 years ago

This was one of the harder issues to solve... simply because it was kind of tricky to reproduce.

It happened because when a document gets deleted from pouchDB, pouchDB will release an event that can be interpreted (by my implementation) that a document (which is a previous version, mostly a conflict) has been added. And my implementation, by design, can never distinguish between a truly new document and such case, unless, I write some sort of persistent list of deleted documents.

So documents kept being deleted then re-added.

In addition to this bug, I noticed few other shortcomings about my implementation, so I trashed the whole thing. And I wrote pouchx a re-usable implementation that will always keep pouchDB and mobx in sync. Using it, everything worked like it should.

alexcorvi commented 5 years ago

Also, delayed input occurs in development build, build in production and you shouldn't see any delay.