diff --git a/composeApp/src/commonMain/kotlin/AppViewModel.kt b/composeApp/src/commonMain/kotlin/AppViewModel.kt index 0ab59a38..aba66cb7 100644 --- a/composeApp/src/commonMain/kotlin/AppViewModel.kt +++ b/composeApp/src/commonMain/kotlin/AppViewModel.kt @@ -14,11 +14,11 @@ class AppViewModel( @Composable fun Init() { LaunchedEffect(Unit) { - initialize() + redirectLoggedUsers() } } - private suspend fun initialize() { + private suspend fun redirectLoggedUsers() { if (sessionManager.getSession() != null) { // already logged navigation.replaceWith(HomeScreen()) diff --git a/composeApp/src/commonMain/kotlin/navigation/Navigation.kt b/composeApp/src/commonMain/kotlin/navigation/Navigation.kt index 0e259c3b..2a67053a 100644 --- a/composeApp/src/commonMain/kotlin/navigation/Navigation.kt +++ b/composeApp/src/commonMain/kotlin/navigation/Navigation.kt @@ -1,6 +1,5 @@ package navigation -import Platform import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue @@ -9,7 +8,6 @@ import ui.screen.NotFoundPage class Navigation( private val systemNavigation: SystemNavigation, - private val platform: Platform, ) { @Composable fun NavHost() { diff --git a/composeApp/src/commonMain/kotlin/ui/screen/home/composable/HomeContent.kt b/composeApp/src/commonMain/kotlin/ui/screen/home/composable/HomeContent.kt index beb44140..16068c3a 100644 --- a/composeApp/src/commonMain/kotlin/ui/screen/home/composable/HomeContent.kt +++ b/composeApp/src/commonMain/kotlin/ui/screen/home/composable/HomeContent.kt @@ -25,11 +25,7 @@ fun HomeContent( onEvent: (HomeViewEvent) -> Unit ) { LearnScaffold( - backButton = BackButton( - onBackClick = { - onEvent(HomeViewEvent.OnBackClick) - } - ), + backButton = null, title = "Learn", actions = { // TODO - update button diff --git a/composeApp/src/jsMain/kotlin/data/storage/LocalStorage.js.kt b/composeApp/src/jsMain/kotlin/data/storage/LocalStorage.js.kt index f1faeac0..32f66726 100644 --- a/composeApp/src/jsMain/kotlin/data/storage/LocalStorage.js.kt +++ b/composeApp/src/jsMain/kotlin/data/storage/LocalStorage.js.kt @@ -1,70 +1,70 @@ package data.storage import kotlinx.browser.window -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext -import org.w3c.dom.get -import org.w3c.dom.set class WebLocalLocalStorage : LocalStorage { override suspend fun putString( key: String, value: String - ) = withContext(Dispatchers.Default) { - window.localStorage[key] = value + ) { + storage.setItem(key, value) } - override suspend fun getString(key: String): String? = withContext(Dispatchers.Default) { - window.localStorage[key] + override suspend fun getString(key: String): String? { + return storage.getItem(key) } override suspend fun putInt( key: String, value: Int - ) = withContext(Dispatchers.Default) { - window.localStorage[key] = value.toString() + ) { + storage.setItem(key, value.toString()) } - override suspend fun getInt(key: String): Int? = withContext(Dispatchers.Default) { - window.localStorage[key]?.toIntOrNull() + override suspend fun getInt(key: String): Int? { + return storage.getItem(key)?.toIntOrNull() } + override suspend fun putDouble( key: String, value: Double - ) = withContext(Dispatchers.Default) { - window.localStorage[key] = value.toString() + ) { + storage.setItem(key, value.toString()) } - override suspend fun getDouble(key: String): Double? = withContext(Dispatchers.Default) { - window.localStorage[key]?.toDoubleOrNull() + override suspend fun getDouble(key: String): Double? { + return storage.getItem(key)?.toDoubleOrNull() } override suspend fun putBoolean( key: String, value: Boolean - ) = withContext(Dispatchers.Default) { - window.localStorage[key] = value.toString() + ) { + storage.setItem(key, value.toString()) } - override suspend fun getBoolean(key: String): Boolean? = withContext(Dispatchers.Default) { - window.localStorage[key]?.toBooleanStrictOrNull() + override suspend fun getBoolean(key: String): Boolean? { + return storage.getItem(key)?.toBooleanStrictOrNull() } override suspend fun remove(key: String) { - window.localStorage.removeItem(key) + storage.removeItem(key) } override suspend fun removeAll() { - window.localStorage.clear() + storage.clear() } override suspend fun keys(): List { - return (0..window.localStorage.length) + return (0..storage.length) .mapNotNull { - window.localStorage.key(it) + storage.key(it) } } + + private val storage + get() = window.localStorage } actual fun localStorage(): LocalStorage = WebLocalLocalStorage() \ No newline at end of file diff --git a/composeApp/src/jsMain/kotlin/navigation/SystemNavigation.js.kt b/composeApp/src/jsMain/kotlin/navigation/SystemNavigation.js.kt index b9f0a8ee..425a5936 100644 --- a/composeApp/src/jsMain/kotlin/navigation/SystemNavigation.js.kt +++ b/composeApp/src/jsMain/kotlin/navigation/SystemNavigation.js.kt @@ -30,6 +30,7 @@ class WebSystemNavigation : SystemNavigation { override fun replaceWith(screen: Screen) { window.history.replaceState(js("({})"), "", screen.toFullPath()) + emitCurrentRoute() } private fun Screen.toFullPath(): String { diff --git a/server/src/main/kotlin/ivy/learn/api/GoogleAuthenticationApi.kt b/server/src/main/kotlin/ivy/learn/api/GoogleAuthenticationApi.kt index cb179ef3..3f5663f2 100644 --- a/server/src/main/kotlin/ivy/learn/api/GoogleAuthenticationApi.kt +++ b/server/src/main/kotlin/ivy/learn/api/GoogleAuthenticationApi.kt @@ -32,7 +32,7 @@ class GoogleAuthenticationApi( val auth = authService.authenticate(googleAuthCode) .mapLeft(ServerError::Unknown) .bind() - val sessionToken = auth.session.token + val sessionToken = auth.session.token.value val frontEndUrl = if (serverMode.devMode) { IvyUrls.devFrontEnd } else { diff --git a/server/src/main/kotlin/ivy/learn/domain/auth/GoogleOAuthUseCase.kt b/server/src/main/kotlin/ivy/learn/domain/auth/GoogleOAuthUseCase.kt index d5384fed..03e168cc 100644 --- a/server/src/main/kotlin/ivy/learn/domain/auth/GoogleOAuthUseCase.kt +++ b/server/src/main/kotlin/ivy/learn/domain/auth/GoogleOAuthUseCase.kt @@ -32,7 +32,7 @@ class GoogleOAuthUseCase( names = userInfoResponse.name, profilePictureUrl = userInfoResponse.picture, ).also { - logger.info("Google verification succeeded for $it") + logger.debug("Google verification succeeded for {}", it) } }