diff --git a/composeApp/src/androidMain/kotlin/org/ooni/probe/background/AppWorkerManager.kt b/composeApp/src/androidMain/kotlin/org/ooni/probe/background/AppWorkerManager.kt index be6a9963..6e2f98ca 100644 --- a/composeApp/src/androidMain/kotlin/org/ooni/probe/background/AppWorkerManager.kt +++ b/composeApp/src/androidMain/kotlin/org/ooni/probe/background/AppWorkerManager.kt @@ -62,6 +62,7 @@ class AppWorkerManager( suspend fun configureDescriptorAutoUpdate(): Boolean { return withContext(backgroundDispatcher) { val request = PeriodicWorkRequestBuilder(1, TimeUnit.DAYS) + .setInitialDelay(1, TimeUnit.DAYS) // avoid immediate start .build() workManager.enqueueUniquePeriodicWork( DescriptorUpdateWorker.AutoUpdateWorkerName, diff --git a/composeApp/src/androidMain/kotlin/org/ooni/probe/background/DescriptorUpdateWorker.kt b/composeApp/src/androidMain/kotlin/org/ooni/probe/background/DescriptorUpdateWorker.kt index 0957d22f..198bb07a 100644 --- a/composeApp/src/androidMain/kotlin/org/ooni/probe/background/DescriptorUpdateWorker.kt +++ b/composeApp/src/androidMain/kotlin/org/ooni/probe/background/DescriptorUpdateWorker.kt @@ -44,7 +44,10 @@ class DescriptorUpdateWorker( override suspend fun doWork(): Result { try { val descriptors = getDescriptors() ?: return Result.failure() - if (descriptors.isEmpty()) return Result.success(buildWorkData(descriptors.map { it.id })) + if (descriptors.isEmpty()) { + Logger.i("Skipping DescriptorUpdateWorker: no descriptors to update") + return Result.success(buildWorkData(descriptors.map { it.id })) + } dependencies.getDescriptorUpdate.invoke(descriptors) return Result.success(buildWorkData(descriptors.map { it.id })) } catch (e: CancellationException) { @@ -57,7 +60,8 @@ class DescriptorUpdateWorker( val descriptorsJson = inputData.getString(DATA_KEY_DESCRIPTORS) if (descriptorsJson != null) { try { - val ids = json.decodeFromString>(descriptorsJson) + val ids = + json.decodeFromString>(descriptorsJson) return testDescriptorRepository.selectByRunIds(ids).first() } catch (e: SerializationException) { Logger.w("Could not start update worker: invalid configuration", e) diff --git a/composeApp/src/commonMain/kotlin/org/ooni/probe/App.kt b/composeApp/src/commonMain/kotlin/org/ooni/probe/App.kt index 884d4273..dcfcc190 100644 --- a/composeApp/src/commonMain/kotlin/org/ooni/probe/App.kt +++ b/composeApp/src/commonMain/kotlin/org/ooni/probe/App.kt @@ -97,6 +97,8 @@ fun App( LaunchedEffect(Unit) { dependencies.bootstrapTestDescriptors() dependencies.bootstrapPreferences() + dependencies.configureDescriptorAutoUpdate() + dependencies.fetchDescriptorUpdate(null) } LaunchedEffect(Unit) { dependencies.finishInProgressData() @@ -104,10 +106,6 @@ fun App( LaunchedEffect(Unit) { dependencies.observeAndConfigureAutoRun() } - LaunchedEffect(Unit) { - dependencies.configureDescriptorAutoUpdate() - dependencies.fetchDescriptorUpdate(null) - } LaunchedEffect(deepLink) { when (deepLink) { diff --git a/composeApp/src/dwMain/kotlin/org/ooni/probe/domain/OrganizationSettings.kt b/composeApp/src/dwMain/kotlin/org/ooni/probe/domain/OrganizationSettings.kt index 05538846..98fb257b 100644 --- a/composeApp/src/dwMain/kotlin/org/ooni/probe/domain/OrganizationSettings.kt +++ b/composeApp/src/dwMain/kotlin/org/ooni/probe/domain/OrganizationSettings.kt @@ -11,6 +11,6 @@ fun webConnectivityPreferences( return emptyList() } -fun preferenceDefaults(): List> { +fun preferenceDefaults(): List> { return emptyList() }