|
|
|
@ -13,6 +13,7 @@ import org.koitharu.kotatsu.core.network.cookies.MutableCookieJar
|
|
|
|
import org.koitharu.kotatsu.core.parser.CachingMangaRepository
|
|
|
|
import org.koitharu.kotatsu.core.parser.CachingMangaRepository
|
|
|
|
import org.koitharu.kotatsu.core.parser.MangaRepository
|
|
|
|
import org.koitharu.kotatsu.core.parser.MangaRepository
|
|
|
|
import org.koitharu.kotatsu.core.parser.ParserMangaRepository
|
|
|
|
import org.koitharu.kotatsu.core.parser.ParserMangaRepository
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.core.prefs.AppSettings
|
|
|
|
import org.koitharu.kotatsu.core.prefs.SourceSettings
|
|
|
|
import org.koitharu.kotatsu.core.prefs.SourceSettings
|
|
|
|
import org.koitharu.kotatsu.core.ui.BaseViewModel
|
|
|
|
import org.koitharu.kotatsu.core.ui.BaseViewModel
|
|
|
|
import org.koitharu.kotatsu.core.ui.util.ReversibleAction
|
|
|
|
import org.koitharu.kotatsu.core.ui.util.ReversibleAction
|
|
|
|
@ -36,12 +37,14 @@ class SourceSettingsViewModel @Inject constructor(
|
|
|
|
|
|
|
|
|
|
|
|
val onActionDone = MutableEventFlow<ReversibleAction>()
|
|
|
|
val onActionDone = MutableEventFlow<ReversibleAction>()
|
|
|
|
val username = MutableStateFlow<String?>(null)
|
|
|
|
val username = MutableStateFlow<String?>(null)
|
|
|
|
|
|
|
|
val browserUrl = MutableStateFlow<String?>(null)
|
|
|
|
val isEnabled = mangaSourcesRepository.observeIsEnabled(source)
|
|
|
|
val isEnabled = mangaSourcesRepository.observeIsEnabled(source)
|
|
|
|
private var usernameLoadJob: Job? = null
|
|
|
|
private var usernameLoadJob: Job? = null
|
|
|
|
|
|
|
|
|
|
|
|
init {
|
|
|
|
init {
|
|
|
|
when (repository) {
|
|
|
|
when (repository) {
|
|
|
|
is ParserMangaRepository -> {
|
|
|
|
is ParserMangaRepository -> {
|
|
|
|
|
|
|
|
browserUrl.value = "https://${repository.domain}"
|
|
|
|
repository.getConfig().subscribe(this)
|
|
|
|
repository.getConfig().subscribe(this)
|
|
|
|
loadUsername(repository.getAuthProvider())
|
|
|
|
loadUsername(repository.getAuthProvider())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -58,11 +61,14 @@ class SourceSettingsViewModel @Inject constructor(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
|
|
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
|
|
|
when (repository) {
|
|
|
|
if (repository is CachingMangaRepository) {
|
|
|
|
is CachingMangaRepository -> {
|
|
|
|
if (key != SourceSettings.KEY_SLOWDOWN && key != SourceSettings.KEY_SORT_ORDER) {
|
|
|
|
if (key != SourceSettings.KEY_SLOWDOWN && key != SourceSettings.KEY_SORT_ORDER) {
|
|
|
|
repository.invalidateCache()
|
|
|
|
repository.invalidateCache()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (repository is ParserMangaRepository) {
|
|
|
|
|
|
|
|
if (key == AppSettings.KEY_OPEN_BROWSER) {
|
|
|
|
|
|
|
|
browserUrl.value = "https://${repository.domain}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|