Skip to content

Commit

Permalink
use backend for show remaining due counts
Browse files Browse the repository at this point in the history
  • Loading branch information
MorenoTropical committed Nov 20, 2024
1 parent 7bc5f15 commit 026ff16
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ class AppearanceSettingsFragment : SettingsFragment() {
// Represents the collection pref "dueCounts": i.e.
// whether the remaining number of cards should be shown.
requirePreference<SwitchPreferenceCompat>(R.string.show_progress_preference).apply {
launchCatchingTask { isChecked = withCol { config.get("dueCounts") ?: true } }
launchCatchingTask { isChecked = withCol { getPreferences().reviewing.showRemainingDueCounts } }
setOnPreferenceChangeListener { _, newDueCountsValue ->
val newDueCountsValueBool = newDueCountsValue as? Boolean ?: return@setOnPreferenceChangeListener false
launchCatchingTask { withCol { config.set("dueCounts", newDueCountsValueBool) } }
launchCatchingTask { setShowRemainingDueCounts(newDueCountsValueBool) }
true
}
}
Expand Down Expand Up @@ -199,6 +199,15 @@ class AppearanceSettingsFragment : SettingsFragment() {
undoableOp { setPreferences(newPrefs) }
Timber.i("Set showIntervalsOnButtons to %b", value)
}

private suspend fun setShowRemainingDueCounts(value: Boolean) {
val prefs = withCol { getPreferences() }
val newPrefs = prefs.copy {
reviewing = reviewing.copy { showRemainingDueCounts = value }
}
undoableOp { setPreferences(newPrefs) }
Timber.i("Set showRemainingDueCounts to %b", value)
}
}

suspend fun getShowIntervalOnButtons(): Boolean =
Expand Down

0 comments on commit 026ff16

Please sign in to comment.