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) },
|
onClick = { screenModel.toggleFilter(LibraryPreferences::filterCompleted) },
|
||||||
)
|
)
|
||||||
|
|
||||||
when (screenModel.trackServices.size) {
|
val trackServices = remember { screenModel.trackServices }
|
||||||
|
when (trackServices.size) {
|
||||||
0 -> {
|
0 -> {
|
||||||
// No trackers
|
// No trackers
|
||||||
}
|
}
|
||||||
1 -> {
|
1 -> {
|
||||||
val service = screenModel.trackServices[0]
|
val service = trackServices[0]
|
||||||
val filterTracker by screenModel.libraryPreferences.filterTracking(service.id.toInt()).collectAsState()
|
val filterTracker by screenModel.libraryPreferences.filterTracking(service.id.toInt()).collectAsState()
|
||||||
TriStateItem(
|
TriStateItem(
|
||||||
label = stringResource(R.string.action_filter_tracked),
|
label = stringResource(R.string.action_filter_tracked),
|
||||||
|
@ -135,7 +136,7 @@ private fun ColumnScope.FilterPage(
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
HeadingItem(R.string.action_filter_tracked)
|
HeadingItem(R.string.action_filter_tracked)
|
||||||
screenModel.trackServices.map { service ->
|
trackServices.map { service ->
|
||||||
val filterTracker by screenModel.libraryPreferences.filterTracking(service.id.toInt()).collectAsState()
|
val filterTracker by screenModel.libraryPreferences.filterTracking(service.id.toInt()).collectAsState()
|
||||||
TriStateItem(
|
TriStateItem(
|
||||||
label = stringResource(service.nameRes()),
|
label = stringResource(service.nameRes()),
|
||||||
|
|
|
@ -225,7 +225,6 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
||||||
val skippedUpdates = CopyOnWriteArrayList<Pair<Manga, String?>>()
|
val skippedUpdates = CopyOnWriteArrayList<Pair<Manga, String?>>()
|
||||||
val failedUpdates = CopyOnWriteArrayList<Pair<Manga, String?>>()
|
val failedUpdates = CopyOnWriteArrayList<Pair<Manga, String?>>()
|
||||||
val hasDownloads = AtomicBoolean(false)
|
val hasDownloads = AtomicBoolean(false)
|
||||||
val loggedServices by lazy { trackManager.services.filter { it.isLogged } }
|
|
||||||
val restrictions = libraryPreferences.libraryUpdateMangaRestriction().get()
|
val restrictions = libraryPreferences.libraryUpdateMangaRestriction().get()
|
||||||
|
|
||||||
coroutineScope {
|
coroutineScope {
|
||||||
|
@ -290,6 +289,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
||||||
}
|
}
|
||||||
|
|
||||||
if (libraryPreferences.autoUpdateTrackers().get()) {
|
if (libraryPreferences.autoUpdateTrackers().get()) {
|
||||||
|
val loggedServices = trackManager.services.filter { it.isLogged }
|
||||||
updateTrackings(manga, loggedServices)
|
updateTrackings(manga, loggedServices)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,11 @@ class LibrarySettingsScreenModel(
|
||||||
val libraryPreferences: LibraryPreferences = Injekt.get(),
|
val libraryPreferences: LibraryPreferences = Injekt.get(),
|
||||||
private val setDisplayModeForCategory: SetDisplayModeForCategory = Injekt.get(),
|
private val setDisplayModeForCategory: SetDisplayModeForCategory = Injekt.get(),
|
||||||
private val setSortModeForCategory: SetSortModeForCategory = Injekt.get(),
|
private val setSortModeForCategory: SetSortModeForCategory = Injekt.get(),
|
||||||
trackManager: TrackManager = Injekt.get(),
|
private val trackManager: TrackManager = Injekt.get(),
|
||||||
) : ScreenModel {
|
) : ScreenModel {
|
||||||
|
|
||||||
val trackServices = trackManager.services.filter { service -> service.isLogged }
|
val trackServices
|
||||||
|
get() = trackManager.services.filter { it.isLogged }
|
||||||
|
|
||||||
fun togglePreference(preference: (LibraryPreferences) -> Preference<Boolean>) {
|
fun togglePreference(preference: (LibraryPreferences) -> Preference<Boolean>) {
|
||||||
preference(libraryPreferences).toggle()
|
preference(libraryPreferences).toggle()
|
||||||
|
|
Reference in a new issue