fix(android): relax constraints on post update worker

This commit is contained in:
Harsh Shandilya 2024-02-07 00:24:35 +05:30
parent fa57bc9695
commit c293fced8a

View file

@ -1,5 +1,5 @@
/* /*
* Copyright © 2021-2023 Harsh Shandilya. * Copyright © 2021-2024 Harsh Shandilya.
* Use of this source code is governed by an MIT-style * Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at * license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT. * https://opensource.org/licenses/MIT.
@ -34,19 +34,12 @@ class ClawApplication : Application(), ApplicationComponentOwner {
plugins.forEach { plugin -> plugin.apply(this) } plugins.forEach { plugin -> plugin.apply(this) }
val postUpdateWorkRequest = val postUpdateWorkRequest =
PeriodicWorkRequestBuilder<SavedPostUpdaterWorker>(POST_REFRESH_PERIOD, TimeUnit.HOURS) PeriodicWorkRequestBuilder<SavedPostUpdaterWorker>(POST_REFRESH_PERIOD, TimeUnit.HOURS)
.setConstraints( .setConstraints(Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build())
Constraints.Builder()
.setRequiresCharging(false)
.setRequiresBatteryNotLow(true)
.setRequiredNetworkType(NetworkType.CONNECTED)
.setRequiresDeviceIdle(true)
.build()
)
.build() .build()
WorkManager.getInstance(this) WorkManager.getInstance(this)
.enqueueUniquePeriodicWork( .enqueueUniquePeriodicWork(
"updateSavedPosts", "updateSavedPosts",
ExistingPeriodicWorkPolicy.UPDATE, ExistingPeriodicWorkPolicy.KEEP,
postUpdateWorkRequest, postUpdateWorkRequest,
) )
} }