From 0dfc1b3e6542b9deca6c56236b46e71e4c6976f5 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 23 Feb 2020 16:36:31 -0800 Subject: Remove singleton pattern for fbcookie --- app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt index 449f0ab0..9fe4c4c9 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt @@ -35,13 +35,17 @@ import com.pitchedapps.frost.utils.showWebContextMenu import com.pitchedapps.frost.views.FrostWebView import kotlinx.coroutines.channels.SendChannel import kotlinx.coroutines.launch +import org.koin.android.ext.android.inject +import org.koin.core.KoinComponent +import org.koin.core.inject /** * Created by Allan Wang on 2017-06-01. */ class FrostJSI(val web: FrostWebView) { - private val prefs: Prefs = web.prefs + private val fbCookie: FbCookie get() = web.fbCookie + private val prefs: Prefs get() = web.prefs private val context: Context = web.context private val activity: MainActivity? = context as? MainActivity private val header: SendChannel? = activity?.headerBadgeChannel @@ -80,7 +84,7 @@ class FrostJSI(val web: FrostWebView) { @JavascriptInterface fun contextMenu(url: String?, text: String?) { // url will be formatted through webcontext - web.post { context.showWebContextMenu(WebContext(url.takeIf { it.isIndependent }, text)) } + web.post { context.showWebContextMenu(WebContext(url.takeIf { it.isIndependent }, text), fbCookie) } } /** @@ -114,7 +118,7 @@ class FrostJSI(val web: FrostWebView) { fun loadLogin() { L.d { "Sign up button found; load login" } context.ctxCoroutine.launch { - FbCookie.logout(context) + fbCookie.logout(context) } } -- cgit v1.2.3