ankidroid / ankidroid/Anki-Android

Proposal: Support sync from any activity

Abierto
#20,721 3 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Kotlin
Estrellas
11.8k
Forks
2.9k
Merge medio
2 d 3 h
PR fusionados (30 d)
171

Descripción

> [!NOTE]
> This only intends for our syncing mechanism supports this use case, not implementation
> Even when implemented, this will not introduce a 'sync' button on every screen.

As part of a DeckPicker refactoring, I will need to move sync logic to a ViewModel.

In future, I would like to allow `MSG_DO_SYNC`, and addons to be able to sync from any screen, without requiring that the user opens the DeckPicker.

Much of DeckPicker's complexity stems from the following issues:

* What if the collection/backend is not usable
* What if the collection is syncing
* `CollectionManager.queue` uses `Dispatchers.IO.limitedParallelism(1)`, therefore blocking all future calls until syncing is completed, and the backend itself blocks access to the collection
* Handling `Message` from other screens in the app

Handling sync externally (via a `SyncManager`) would reduce complexity

### Issues/Considerations

These issues are currently present:

* What should `withCol` calls do? Block or cancel pending work?
* Some mutations may no longer be valid for the new collection
* Some 'valid' operations could be lost, whereas recovery is reasonable (`addNote`, assuming the note type still exists)
* What should the API do while syncing?
* What happens if the user is within a method with multiple `withCol` calls when syncing occurs
* `ReviewerViewModel.answerCardInternal` would want consideration

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.