diff --git a/app/src/main/java/eu/kanade/domain/source/interactor/ToggleSource.kt b/app/src/main/java/eu/kanade/domain/source/interactor/ToggleSource.kt index bb602da5c..e69e76dab 100644 --- a/app/src/main/java/eu/kanade/domain/source/interactor/ToggleSource.kt +++ b/app/src/main/java/eu/kanade/domain/source/interactor/ToggleSource.kt @@ -18,6 +18,13 @@ class ToggleSource( } } + fun await(sourceIds: List, enable: Boolean) { + val transformedSourceIds = sourceIds.map { it.toString() } + preferences.disabledSources().getAndSet { disabled -> + if (enable) disabled.minus(transformedSourceIds) else disabled.plus(transformedSourceIds) + } + } + private fun isEnabled(sourceId: Long): Boolean { return sourceId.toString() in preferences.disabledSources().get() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsPresenter.kt index 3e972394e..1ddc124c5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsPresenter.kt @@ -118,7 +118,9 @@ class ExtensionDetailsPresenter( } fun toggleSources(enable: Boolean) { - extension?.sources?.forEach { toggleSource.await(it.id, enable) } + extension?.sources + ?.map { it.id } + ?.let { toggleSource.await(it, enable) } } private fun createUrl(url: String, pkgName: String, pkgFactory: String?, path: String = ""): String {