fix: watch positions can't be reset

This commit is contained in:
Bnyro 2023-11-02 13:41:03 +01:00
parent 2940f4a6f9
commit db91919cb6

View File

@ -1,13 +1,13 @@
package com.github.libretube.ui.preferences
import android.os.Bundle
import androidx.lifecycle.lifecycleScope
import androidx.preference.Preference
import com.github.libretube.R
import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.db.DatabaseHolder.Database
import com.github.libretube.ui.base.BasePreferenceFragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@ -53,15 +53,15 @@ class HistorySettings : BasePreferenceFragment() {
}
}
private fun showClearDialog(title: Int, action: suspend () -> Unit) {
private fun showClearDialog(title: Int, actionOnConfirm: suspend () -> Unit) {
MaterialAlertDialogBuilder(requireContext())
.setTitle(title)
.setMessage(R.string.irreversible)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.okay) { _, _ ->
// clear the selected preference preferences
lifecycleScope.launch(Dispatchers.IO) {
action()
CoroutineScope(Dispatchers.IO).launch {
actionOnConfirm.invoke()
}
}
.show()