digidem / mapeo-core-next

The upcoming version of Mapeo Core
MIT License
7 stars 1 forks source link

Expose API to stop syncing when app goes into background #576

Closed EvanHahn closed 1 month ago

EvanHahn commented 3 months ago

When CoMapeo goes into the background, we should gracefully shut down sync.

For this task, that means the following:

  1. Add a function like shutdownSync[^1], which the frontend will call when the app goes into the background.
  2. Close the local discovery TCP listener (probably means calling LocalDiscovery.prototype.#stop)
  3. For each open connection...
    1. Stop replicating (similar to blocked) if they haven't started replicating back.
    2. Wait until sync completes. (Likely requires no waiting because the app usually isn't syncing when the app goes into the background.)
    3. Close the connection.

[^1]: Come up with a better name if you can! Please!!