Option to clear new chapters counters
This commit is contained in:
@@ -43,6 +43,9 @@ abstract class TracksDao {
|
||||
@Query("DELETE FROM tracks")
|
||||
abstract suspend fun clear()
|
||||
|
||||
@Query("UPDATE tracks SET chapters_new = 0")
|
||||
abstract suspend fun clearCounters()
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||
abstract suspend fun insert(entity: TrackEntity): Long
|
||||
|
||||
|
||||
@@ -98,6 +98,8 @@ class TrackingRepository @Inject constructor(
|
||||
|
||||
suspend fun clearLogs() = db.trackLogsDao.clear()
|
||||
|
||||
suspend fun clearCounters() = db.tracksDao.clearCounters()
|
||||
|
||||
suspend fun gc() {
|
||||
db.withTransaction {
|
||||
db.tracksDao.gc()
|
||||
|
||||
@@ -6,9 +6,9 @@ import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.core.view.MenuProvider
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.base.ui.dialog.CheckBoxAlertDialog
|
||||
import org.koitharu.kotatsu.settings.SettingsActivity
|
||||
import org.koitharu.kotatsu.tracker.work.TrackWorker
|
||||
|
||||
@@ -39,13 +39,15 @@ class FeedMenuProvider(
|
||||
}
|
||||
|
||||
R.id.action_clear_feed -> {
|
||||
MaterialAlertDialogBuilder(context)
|
||||
CheckBoxAlertDialog.Builder(context)
|
||||
.setTitle(R.string.clear_updates_feed)
|
||||
.setMessage(R.string.text_clear_updates_feed_prompt)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(R.string.clear) { _, _ ->
|
||||
viewModel.clearFeed()
|
||||
}.show()
|
||||
.setCheckBoxChecked(true)
|
||||
.setCheckBoxText(R.string.clear_new_chapters_counters)
|
||||
.setPositiveButton(R.string.clear) { _, isChecked ->
|
||||
viewModel.clearFeed(isChecked)
|
||||
}.create().show()
|
||||
true
|
||||
}
|
||||
|
||||
|
||||
@@ -50,9 +50,12 @@ class FeedViewModel @Inject constructor(
|
||||
}
|
||||
}.asFlowLiveData(viewModelScope.coroutineContext + Dispatchers.Default, listOf(LoadingState))
|
||||
|
||||
fun clearFeed() {
|
||||
fun clearFeed(clearCounters: Boolean) {
|
||||
launchLoadingJob(Dispatchers.Default) {
|
||||
repository.clearLogs()
|
||||
if (clearCounters) {
|
||||
repository.clearCounters()
|
||||
}
|
||||
onFeedCleared.postCall(Unit)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,4 +396,5 @@
|
||||
<string name="network_unavailable">Network is not available</string>
|
||||
<string name="network_unavailable_hint">Turn on Wi-Fi or mobile network to read manga online</string>
|
||||
<string name="server_error">Server side error (%1$d). Please try again later</string>
|
||||
<string name="clear_new_chapters_counters">Also clear information about new chapters</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user