Skip to content

Commit

Permalink
Update: Make FullTextWorker unique
Browse files Browse the repository at this point in the history
  • Loading branch information
machiav3lli committed Dec 16, 2024
1 parent d4f0b76 commit 7fb2f82
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.saulhdev.feeder.models
import android.content.Context
import android.util.Log
import androidx.work.CoroutineWorker
import androidx.work.ExistingWorkPolicy
import androidx.work.OneTimeWorkRequestBuilder
import androidx.work.WorkManager
import androidx.work.WorkerParameters
Expand All @@ -26,7 +27,11 @@ fun scheduleFullTextParse() {
.addTag("FullTextWorker")
.keepResultsForAtLeast(1, TimeUnit.MINUTES)
val workManager: WorkManager by inject(WorkManager::class.java)
workManager.enqueue(workRequest.build())
workManager.enqueueUniqueWork(
"FullTextWorker",
ExistingWorkPolicy.KEEP,
workRequest.build()
)
}

class FullTextWorker(
Expand Down

0 comments on commit 7fb2f82

Please sign in to comment.