Fix auto captcha opening when you dont have the option enabled (temp fix)

This commit is contained in:
Jobobby04
2020-07-24 12:36:20 -04:00
parent f3b6855684
commit a311a3b497
2 changed files with 8 additions and 6 deletions
@@ -1,8 +1,11 @@
package exh.patch
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
typealias EHInterceptor = (request: Request, response: Response, sourceId: Long) -> Response
@@ -16,10 +19,9 @@ fun OkHttpClient.Builder.injectPatches(sourceIdProducer: () -> Long): OkHttpClie
}
fun findAndApplyPatches(sourceId: Long): EHInterceptor {
return (
(EH_INTERCEPTORS[sourceId] ?: emptyList()) +
(EH_INTERCEPTORS[EH_UNIVERSAL_INTERCEPTOR] ?: emptyList())
).merge()
// TODO make it so captcha doesnt auto open in manga eden while applying universal interceptors
return if (Injekt.get<PreferencesHelper>().eh_autoSolveCaptchas().get()) ((EH_INTERCEPTORS[sourceId] ?: emptyList()) + (EH_INTERCEPTORS[EH_UNIVERSAL_INTERCEPTOR] ?: emptyList())).merge()
else (EH_INTERCEPTORS[sourceId] ?: emptyList()).merge()
}
fun List<EHInterceptor>.merge(): EHInterceptor {