hakanu/pervane

Redundant and missing auto-save calls

metanet opened this issue · 2 comments

  1. Start pervane with debugging enabled.
  2. Open a tab in the browser.
  3. Type a single letter and wait for the auto-save trigger.
  4. See the following logs:
INFO:werkzeug:127.0.0.1 - - [07/Jun/2020 23:31:40] "POST /api/update HTTP/1.1" 200 -
INFO:werkzeug:127.0.0.1 - - [07/Jun/2020 23:31:40] "POST /api/update HTTP/1.1" 200 -

For each letter, there are 2 POST calls. If you type 5 letters and wait for the auto-save, there will be 10 POST calls.

On the other hand, if you delete something in the editor, auto-save doesn't get triggered.

Last, if you save by ALT+S, there is only 1 POST call which is the correct behavior.

We listen to change event. And 2 seconds after event is triggered, pervane issues the POST request.

Deletion sounds like a bug. However, first one is the auto save behavior.

What do you recommend instead?

but there are 2 POST requests for each key store. Why is there a second POST? It seems like a bug to me.

Other than that, I think hitting disk for each key stroke is a bit overkill. When I hit 5 keys in 2 seconds before auto-save kicks in, the UI sends 10 POST requests, even if a single POST request would be enough. I think we can optimize this part.