Skip to content

Commit

Permalink
Now really fix internal sources download badges not showing up, plus …
Browse files Browse the repository at this point in the history
…some refactoring and testing debug functions
  • Loading branch information
jobobby04 committed Jul 30, 2020
1 parent e338bb0 commit ff48e89
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import eu.kanade.tachiyomi.data.database.models.Chapter
import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.source.SourceManager
import exh.source.BlacklistedSources
import java.util.concurrent.TimeUnit
import kotlinx.coroutines.flow.onEach
import uy.kohesive.injekt.Injekt
Expand Down Expand Up @@ -124,9 +123,7 @@ class DownloadCache(
*/
private fun renew() {
// SY -->
val onlineSources = sourceManager.getOnlineSources().filter {
it.id !in BlacklistedSources.HIDDEN_SOURCES
}
val onlineSources = sourceManager.getVisibleOnlineSources()
// SY <--

val sourceDirs = rootDir.dir.listFiles()
Expand Down
8 changes: 6 additions & 2 deletions app/src/main/java/eu/kanade/tachiyomi/source/SourceManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import com.elvishew.xlog.XLog
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga
Expand Down Expand Up @@ -31,7 +32,6 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import rx.Observable
import uy.kohesive.injekt.injectLazy

Expand All @@ -52,7 +52,7 @@ open class SourceManager(private val context: Context) {

// SY -->
// Recreate sources when they change
prefs.enableExhentai().asFlow().onEach {
prefs.enableExhentai().asImmediateFlow {
createEHSources().forEach { registerSource(it) }
}.launchIn(scope)

Expand All @@ -72,6 +72,10 @@ open class SourceManager(private val context: Context) {

fun getOnlineSources() = sourcesMap.values.filterIsInstance<HttpSource>()

fun getVisibleOnlineSources() = sourcesMap.values.filterIsInstance<HttpSource>().filter {
it.id !in BlacklistedSources.HIDDEN_SOURCES
}

fun getCatalogueSources() = sourcesMap.values.filterIsInstance<CatalogueSource>()

// SY -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import eu.kanade.tachiyomi.util.preference.switchPreferenceCategory
import eu.kanade.tachiyomi.util.preference.titleRes
import eu.kanade.tachiyomi.util.system.LocaleHelper
import eu.kanade.tachiyomi.widget.preference.SwitchPreferenceCategory
import exh.source.BlacklistedSources
import java.util.TreeMap
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.launchIn
Expand All @@ -36,9 +35,7 @@ class SourceFilterController : SettingsController() {
}

private val onlineSources by lazy {
Injekt.get<SourceManager>().getOnlineSources().filter {
it.id !in BlacklistedSources.HIDDEN_SOURCES
}
Injekt.get<SourceManager>().getVisibleOnlineSources()
}

private var query = ""
Expand Down
15 changes: 13 additions & 2 deletions app/src/main/java/exh/debug/DebugFunctions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,20 @@ object DebugFunctions {

fun clearSavedSearches() = prefs.eh_savedSearches().set(emptySet())

fun listAllSources() = sourceManager.getCatalogueSources().map {
fun listAllSources() = sourceManager.getCatalogueSources().joinToString("\n") {
"${it.id}: ${it.name} (${it.lang.toUpperCase()})"
}.joinToString("\n")
}

fun listFilteredSources() = sourceManager.getVisibleCatalogueSources().joinToString("\n") {
"${it.id}: ${it.name} (${it.lang.toUpperCase()})"
}

fun listAllHttpSources() = sourceManager.getOnlineSources().joinToString("\n") {
"${it.id}: ${it.name} (${it.lang.toUpperCase()})"
}
fun listFilteredHttpSources() = sourceManager.getVisibleOnlineSources().joinToString("\n") {
"${it.id}: ${it.name} (${it.lang.toUpperCase()})"
}

fun convertAllEhentaiGalleriesToExhentai() = convertSources(EH_SOURCE_ID, EXH_SOURCE_ID)

Expand Down

0 comments on commit ff48e89

Please sign in to comment.