diff --git a/app/src/main/java/org/unifiedpush/distributor/nextpush/services/RestartWorker.kt b/app/src/main/java/org/unifiedpush/distributor/nextpush/services/RestartWorker.kt index 8d71fab..5ece2cb 100644 --- a/app/src/main/java/org/unifiedpush/distributor/nextpush/services/RestartWorker.kt +++ b/app/src/main/java/org/unifiedpush/distributor/nextpush/services/RestartWorker.kt @@ -36,16 +36,16 @@ class RestartWorker(ctx: Context, params: WorkerParameters) : Worker(ctx, params companion object { fun start(context: Context, delay: Long? = null) { val work = PeriodicWorkRequestBuilder(16, TimeUnit.MINUTES) - if (delay != null) { + delay?.let { lastEventDate = null - work.setInitialDelay(delay, TimeUnit.SECONDS) + work.setInitialDelay(it, TimeUnit.SECONDS) } - val workManager = WorkManager.getInstance(context) - workManager.enqueueUniquePeriodicWork( - UNIQUE_WORK_TAG, - ExistingPeriodicWorkPolicy.REPLACE, - work.build() - ) + WorkManager.getInstance(context) + .enqueueUniquePeriodicWork( + UNIQUE_WORK_TAG, + ExistingPeriodicWorkPolicy.REPLACE, + work.build() + ) } } }