cozy / cozy-libs

Libraries used to build Cozy products and tools.
MIT License
7 stars 12 forks source link

Make document scan more resilient #2540

Closed zatteo closed 4 months ago

zatteo commented 4 months ago

During a document scan, the mobile operating system can kill the mespapiers webview if the phone is on low memory. When the document scan end, the flagship app detect that mespapiers has been killed and start it again from scratch. So we loose everything we did on the form and we loose the scan.

So here we make it more resilient by :

  1. remembering before a document scan the state of the form browser side
  2. remembering after a document scan the result of the scan native side
  3. when mespapiers is started, mespapiers can check if it needs to restore a form with the data from 1. and 2. to go back to the paper creation modal as if nothing happened :tada:

Linked PR on cozy-flagship-app : https://github.com/cozy/cozy-flagship-app/pull/1208

See it in action (a click on "Cancel" simulate a successful scan in the iOS simulator)

https://github.com/cozy/cozy-libs/assets/10849491/09eed2bc-f5c6-4554-b1c9-aa8305eacc63

Todo