Getprofile in SelectSiteScreen
This commit is contained in:
1 parent
48ed3c8f31
commit
7791fa10f5
5 files changed
+16
-26
No files matched your search
@@ -125,9 +125,6 @@ fun CookieSignInScene(navController: NavController) {
|
||||
runCatching {
|
||||
EhClient.execute(METHOD_GET_PROFILE)
|
||||
}.onSuccess {
|
||||
launchIO {
|
||||
getProfile()
|
||||
}
|
||||
withUIContext {
|
||||
navController.navigate(SELECT_SITE_ROUTE_NAME)
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.hippo.ehviewer.ui.compose
|
||||
|
||||
import com.hippo.ehviewer.Settings
|
||||
import com.hippo.ehviewer.client.EhClient
|
||||
import com.hippo.ehviewer.client.parser.ProfileParser
|
||||
|
||||
suspend fun getProfile() {
|
||||
runCatching {
|
||||
(EhClient.execute(EhClient.METHOD_GET_PROFILE) as ProfileParser.Result).run {
|
||||
Settings.putDisplayName(displayName)
|
||||
Settings.putAvatar(avatar)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,11 @@ import androidx.compose.ui.unit.dp
|
||||
import com.hippo.ehviewer.EhApplication
|
||||
import com.hippo.ehviewer.R
|
||||
import com.hippo.ehviewer.Settings
|
||||
import com.hippo.ehviewer.client.EhClient
|
||||
import com.hippo.ehviewer.client.EhUrl
|
||||
import com.hippo.ehviewer.client.parser.ProfileParser
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
|
||||
@Composable
|
||||
fun SelectSiteScreen(finish: () -> Unit) {
|
||||
@@ -113,6 +117,9 @@ fun SelectSiteScreen(finish: () -> Unit) {
|
||||
Settings.putGallerySite(EhUrl.SITE_E)
|
||||
else
|
||||
Settings.putGallerySite(EhUrl.SITE_EX)
|
||||
GlobalScope.launchIO {
|
||||
getProfile()
|
||||
}
|
||||
finish()
|
||||
}, Modifier.fillMaxWidth()) {
|
||||
Text(text = stringResource(id = android.R.string.ok))
|
||||
@@ -120,3 +127,12 @@ fun SelectSiteScreen(finish: () -> Unit) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getProfile() {
|
||||
runCatching {
|
||||
(EhClient.execute(EhClient.METHOD_GET_PROFILE) as ProfileParser.Result).run {
|
||||
Settings.putDisplayName(displayName)
|
||||
Settings.putAvatar(avatar)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,6 @@ import com.hippo.ehviewer.ui.LoginActivity.Companion.WEBVIEW_SIGN_IN_ROUTE_NAME
|
||||
import com.hippo.util.ExceptionUtils
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.Job
|
||||
import rikka.core.util.ContextUtils.requireActivity
|
||||
|
||||
@@ -117,10 +116,6 @@ fun SignInScreen(navController: NavController) {
|
||||
showErrorDialog = true
|
||||
}
|
||||
}.onSuccess {
|
||||
// This composable is to be finished
|
||||
GlobalScope.launchIO {
|
||||
getProfile()
|
||||
}
|
||||
withUIContext {
|
||||
navController.navigate(SELECT_SITE_ROUTE_NAME)
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import com.hippo.ehviewer.client.EhUrl
|
||||
import com.hippo.ehviewer.client.EhUtils
|
||||
import com.hippo.ehviewer.ui.LoginActivity.Companion.SELECT_SITE_ROUTE_NAME
|
||||
import com.hippo.ehviewer.widget.DialogWebChromeClient
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import okhttp3.Cookie
|
||||
import okhttp3.HttpUrl
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
@@ -99,9 +98,6 @@ fun WebviewSignInScreen(navController: NavController) {
|
||||
if (getId && getHash) {
|
||||
present = true
|
||||
navController.navigate(SELECT_SITE_ROUTE_NAME)
|
||||
launchIO {
|
||||
getProfile()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user