Commit d9c29204 authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Cancel the automatic refresh if it is disabled

parent 5a001f40
Pipeline #5077 passed with stage
in 1 minute and 45 seconds
......@@ -137,6 +137,9 @@ class DnsRuleFragment : Fragment() {
}
}, refreshConfigChanged = {
getPreferences().apply {
val workManager = WorkManager.getInstance(context!!)
workManager.cancelAllWorkByTag("hostSourceRefresh")
if(automaticHostRefresh) {
val constraints = Constraints.Builder()
.setRequiresStorageNotLow(true)
.setRequiresBatteryNotLow(true)
......@@ -160,11 +163,9 @@ class DnsRuleFragment : Fragment() {
.setConstraints(constraints)
.setInitialDelay(mappedTimeAmount, mappedTimeUnit)
.addTag("hostSourceRefresh")
WorkManager.getInstance(context!!).apply {
cancelAllWorkByTag("hostSourceRefresh")
enqueue(workRequest.build())
}
workManager.enqueue(workRequest.build())
}
}
}).show()
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment