ankidroid / ankidroid/Anki-Android

Proposal: Support sync from any activity

Open
#20,721 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
11.8k
Forks
2.9k
Avg merge
2d 3h
Merged PRs (30d)
171

Description

> [!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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.