Skip to content
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

schedule chain sync as unique work #1280

Merged
merged 1 commit into from
May 6, 2024
Merged

Conversation

JssDWt
Copy link
Contributor

@JssDWt JssDWt commented May 3, 2024

An attempt to deduplicate sync jobs at the root level, namely where they're scheduled.

Tested with a firebase notification. The job is still triggered at least. I'm not sure whether it will actually be deduplicated.

@@ -31,6 +32,6 @@ private void startSyncJob(){
.build())
.build();

WorkManager.getInstance().enqueue(oneTime);
WorkManager.getInstance().enqueueUniqueWork(UNIQUE_WORK_NAME, ExistingWorkPolicy.REPLACE, oneTime);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JssDWt did you consider using https://developer.android.com/reference/androidx/work/ExistingWorkPolicy#KEEP ? It looks like the difference is that it won't cancel the pending job and just let it finish.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not consider that, that looks better indeed

Copy link
Contributor Author

@JssDWt JssDWt May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roeierez Testing this out it seems the job is not executed when I use ExistingWorkPolicy.KEEP

@JssDWt JssDWt force-pushed the jssdwt-deparallelize-chainsync branch from 1294cf0 to 0b025c4 Compare May 6, 2024 18:42
@JssDWt JssDWt merged commit 0b025c4 into master May 6, 2024
1 check passed
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.

2 participants