Add back option to hide Updates count (#8709)

Adds back the option to hide the updates count on the Updates tab

(cherry picked from commit 8937e22ce4769818c1908b1ad60914553d1e42e2)
This commit is contained in:
Soitora 2022-12-09 23:25:06 +01:00 committed by Jobobby04
parent af8c4fe835
commit 5ac5005116
4 changed files with 15 additions and 2 deletions

View File

@ -67,6 +67,7 @@ class LibraryPreferences(
fun languageBadge() = preferenceStore.getBoolean("display_language_badge", false)
fun newShowUpdatesCount() = preferenceStore.getBoolean("library_show_updates_count", true)
fun newUpdatesCount() = preferenceStore.getInt("library_unseen_updates_count", 0)
// endregion

View File

@ -41,6 +41,13 @@ object SettingsGeneralScreen : SearchableSettings {
val uiPrefs = remember { Injekt.get<UiPreferences>() }
// SY <--
return mutableListOf<Preference>().apply {
add(
Preference.PreferenceItem.SwitchPreference(
pref = libraryPrefs.newShowUpdatesCount(),
title = stringResource(R.string.pref_library_update_show_tab_badge),
),
)
add(
Preference.PreferenceItem.SwitchPreference(
pref = prefs.confirmExit(),

View File

@ -57,6 +57,7 @@ import eu.kanade.tachiyomi.ui.more.MoreTab
import eu.kanade.tachiyomi.ui.updates.UpdatesTab
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.launch
import soup.compose.material.motion.animation.materialFadeThroughIn
@ -251,8 +252,11 @@ object HomeScreen : Screen {
when {
tab is UpdatesTab -> {
val count by produceState(initialValue = 0) {
Injekt.get<LibraryPreferences>()
.newUpdatesCount().changes()
val pref = Injekt.get<LibraryPreferences>()
combine(
pref.newShowUpdatesCount().changes(),
pref.newUpdatesCount().changes(),
) { show, count -> if (show) count else 0 }
.collectLatest { value = it }
}
if (count > 0) {

View File

@ -254,6 +254,7 @@
<string name="pref_update_only_completely_read">With unread chapter(s)</string>
<string name="pref_update_only_non_completed">With \"Completed\" status</string>
<string name="pref_update_only_started">That haven\'t been started</string>
<string name="pref_library_update_show_tab_badge">Show unread count on Updates icon</string>
<string name="pref_library_update_refresh_metadata">Automatically refresh metadata</string>
<string name="pref_library_update_refresh_metadata_summary">Check for new cover and details when updating library</string>
<string name="pref_library_update_refresh_trackers">Automatically refresh trackers</string>