mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Get current track services when composing LibrarySettingsDialog
Fixes #9431
This commit is contained in:
parent
921a988c4a
commit
14c465d36f
3 changed files with 8 additions and 6 deletions
|
@ -120,12 +120,13 @@ private fun ColumnScope.FilterPage(
|
|||
onClick = { screenModel.toggleFilter(LibraryPreferences::filterCompleted) },
|
||||
)
|
||||
|
||||
when (screenModel.trackServices.size) {
|
||||
val trackServices = remember { screenModel.trackServices }
|
||||
when (trackServices.size) {
|
||||
0 -> {
|
||||
// No trackers
|
||||
}
|
||||
1 -> {
|
||||
val service = screenModel.trackServices[0]
|
||||
val service = trackServices[0]
|
||||
val filterTracker by screenModel.libraryPreferences.filterTracking(service.id.toInt()).collectAsState()
|
||||
TriStateItem(
|
||||
label = stringResource(R.string.action_filter_tracked),
|
||||
|
@ -135,7 +136,7 @@ private fun ColumnScope.FilterPage(
|
|||
}
|
||||
else -> {
|
||||
HeadingItem(R.string.action_filter_tracked)
|
||||
screenModel.trackServices.map { service ->
|
||||
trackServices.map { service ->
|
||||
val filterTracker by screenModel.libraryPreferences.filterTracking(service.id.toInt()).collectAsState()
|
||||
TriStateItem(
|
||||
label = stringResource(service.nameRes()),
|
||||
|
|
|
@ -225,7 +225,6 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
|||
val skippedUpdates = CopyOnWriteArrayList<Pair<Manga, String?>>()
|
||||
val failedUpdates = CopyOnWriteArrayList<Pair<Manga, String?>>()
|
||||
val hasDownloads = AtomicBoolean(false)
|
||||
val loggedServices by lazy { trackManager.services.filter { it.isLogged } }
|
||||
val restrictions = libraryPreferences.libraryUpdateMangaRestriction().get()
|
||||
|
||||
coroutineScope {
|
||||
|
@ -290,6 +289,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
|||
}
|
||||
|
||||
if (libraryPreferences.autoUpdateTrackers().get()) {
|
||||
val loggedServices = trackManager.services.filter { it.isLogged }
|
||||
updateTrackings(manga, loggedServices)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,10 +23,11 @@ class LibrarySettingsScreenModel(
|
|||
val libraryPreferences: LibraryPreferences = Injekt.get(),
|
||||
private val setDisplayModeForCategory: SetDisplayModeForCategory = Injekt.get(),
|
||||
private val setSortModeForCategory: SetSortModeForCategory = Injekt.get(),
|
||||
trackManager: TrackManager = Injekt.get(),
|
||||
private val trackManager: TrackManager = Injekt.get(),
|
||||
) : ScreenModel {
|
||||
|
||||
val trackServices = trackManager.services.filter { service -> service.isLogged }
|
||||
val trackServices
|
||||
get() = trackManager.services.filter { it.isLogged }
|
||||
|
||||
fun togglePreference(preference: (LibraryPreferences) -> Preference<Boolean>) {
|
||||
preference(libraryPreferences).toggle()
|
||||
|
|
Loading…
Reference in a new issue