Skip to content

fix/autosave timer#8917

Draft
max-nextcloud wants to merge 9 commits into
mainfrom
fix/autosave-timer
Draft

fix/autosave timer#8917
max-nextcloud wants to merge 9 commits into
mainfrom
fix/autosave-timer

Conversation

@max-nextcloud

Copy link
Copy Markdown
Collaborator
  • fix(autosave): every time the typing stops
  • chore(refactor): document tracking into provideSyncService
  • fix(autosave): only save when server is ready
  • fix(autosave): better dirty tracking with versions
  • chore(refactor): Save service with its own bus
  • chore(refactor): separate SaveService from SyncService and ydoc
  • fix(autosave): exponential delay for retries on error
  • fix(autosave): retry if server throttled save request
  • fix(autosave): handle out of sync clocks

Debounce will delay the execution of the function every time it is called.
So autosave was waiting until no updates occured for 30 seconds.

That's a long time and does not feel responsive.
Try to autosave every time the user stops typing for at least one second.

Signed-off-by: Max <max@nextcloud.com>
Also removed the document attribute from the `sync` event load.
It is already included in the `change` event load.

Signed-off-by: Max <max@nextcloud.com>
The server will only accept autosaves every 10 seconds.
`document` contains the last saved timestamp.
Compute the time to autosave next.
Add a small random delay (up to 3 seconds)
to avoid all connected clients from saving at the same time.

Signed-off-by: Max <max@nextcloud.com>
Keep track of the version that has our changes
and compare it to the last saved version on the server.

This allows fixing two scenarios:
* Server response happily to save but does not actually save.
  The server will only save new versions every 10 seconds.
  If the latest save just happened it will still respond with 200
  but list the outdated version in the response.
  Comparing the versions shows that our changes have not been saved yet.
* Other user already saved the file.
  our changes.
  So far dirty would stay true until WE save our changes.
  Comparing the versions also shows the file was saved
  when it was saved by someone else.

Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
* `getSaveData` now prepares the data to send to the server.
* `provideSaveService` now handles all the sync service events
  calling functions on `saveService` where needed.

Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
The server will only perform one actual save every 10 seconds.

Trigger another autosave if the save attempt was throttled.
`document` is udpated by throttled save attempts.
Rely on its `lastSavedVersionTime` for the retry.

Signed-off-by: Max <max@nextcloud.com>
* If the server claims to have saved the doc in the future
  use the current timestamp instead.
  Autosave happens at least ten seconds after `lastSavedVersionTime`.
  So if that was far into the future it would never happen.

* If the server is living in the past
  delay the autosave retries
  without relying on `lastSavedVersionTime`.

Signed-off-by: Max <max@nextcloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant