feat: Option to prune finished workers

This commit is contained in:
Ahmad Ansori Palembani 2024-09-24 08:40:32 +07:00
parent 7719847106
commit dbd007127d
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6

View file

@ -66,6 +66,7 @@ import eu.kanade.tachiyomi.util.system.localeContext
import eu.kanade.tachiyomi.util.system.materialAlertDialog
import eu.kanade.tachiyomi.util.system.setDefaultSettings
import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.util.system.workManager
import eu.kanade.tachiyomi.util.view.openInBrowser
import eu.kanade.tachiyomi.util.view.setMessage
import eu.kanade.tachiyomi.util.view.setPositiveButton
@ -418,6 +419,20 @@ class SettingsAdvancedController : SettingsLegacyController() {
.show()
}
}
preference {
title = "Prune finished workers"
summary = "In case worker stuck in FAILED state and you're too impatient to wait"
onClick {
activity!!.materialAlertDialog()
.setTitle("Are you sure?")
.setMessage("Failed workers should clear out by itself eventually, " +
"this option should only be used if you're being impatient and you know what you're doing.")
.setPositiveButton("Prune") { _, _ -> context.workManager.pruneWork() }
.setNegativeButton("Cancel", null)
.show()
}
}
}
@OptIn(DelicateCoroutinesApi::class)