-
-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sync on collection update #1240
base: main-ose
Are you sure you want to change the base?
Sync on collection update #1240
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder how this behaves when the services are refreshed. Doesn't it enqueue a lot of syncs during service detection (whenever a collection is updated)?
My ideas (may or may not make sense):
- A delay of a few seconds between the collection change and the sync (like for the push registration) could at least reduce the number of synchronizations during service detection.
- Or maybe pause it somehow?
- Maybe separate callbacks for the actions we want to observe (update read-only, update sync flag)? Has advantages and disadvantages.
/** | ||
* Listener that enqueues a push registration worker when the collection list changes. | ||
*/ | ||
class CollectionsListener @Inject constructor( | ||
private val workerManager: SyncWorkerManager | ||
): DavCollectionRepository.OnChangeListener { | ||
|
||
override fun onCollectionsChanged(account: Account?) { | ||
account?.let { workerManager.enqueueOneTimeAllAuthorities(it) } | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Hilt module that registers [CollectionsListener] in [DavCollectionRepository]. | ||
*/ | ||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
interface SyncWorkerManagerModule { | ||
@Binds | ||
@IntoSet | ||
fun listener(impl: CollectionsListener): DavCollectionRepository.OnChangeListener | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be in a separate file, because SyncWorkerManager
's task is only to manage (enqueue, cancel) syncs.
The functionality that a method of SyncWorkerManager
shall be called when collections change is a separate function and should be in a separate file.
Purpose
Nice to have for:
Short description
SyncWorkerManager
listen to any collection changes and use the account passed along to trigger a one time sync of the whole account (not just the service which the collection belongs to - although that would prob be possible as well).Checklist