fix deep link
This commit is contained in:
+8
-1
@@ -102,6 +102,7 @@ object UrlRoutes {
|
||||
}
|
||||
),
|
||||
|
||||
// "/chat
|
||||
rule(
|
||||
match = { it is Route.Chat },
|
||||
build = {
|
||||
@@ -110,7 +111,13 @@ object UrlRoutes {
|
||||
emptyMap()
|
||||
)
|
||||
},
|
||||
parse = { _, _ -> Route.Chat() }
|
||||
parse = { segs, _ ->
|
||||
if (segs.size == 1 && segs[0] == Seg.CHAT) {
|
||||
Route.Chat()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
),
|
||||
|
||||
// "/search"
|
||||
|
||||
+13
-11
@@ -10,7 +10,6 @@ import com.arkivanov.essenty.lifecycle.coroutines.repeatOnLifecycle
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.flow.flatMapLatest
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.serialization.KSerializer
|
||||
import org.koin.core.Koin
|
||||
@@ -27,26 +26,29 @@ import ru.shadowsparky.vbox.shared.presentation.nav.Route
|
||||
class VBoxRootComponent(
|
||||
componentContext: ComponentContext,
|
||||
tokenStorage: TokenStorage,
|
||||
override val initStack: List<Route>,
|
||||
private val initRoute: Route,
|
||||
private val healthCheck: HeathCheck,
|
||||
val imageLoaderProvider: ImageLoaderProvider,
|
||||
updateComponentFactory: UpdateComponentFactory,
|
||||
private val remoteEventListener: RemoteEventListener,
|
||||
override val initStack: List<Route> = listOf(initRoute),
|
||||
override val serializer: KSerializer<Route> = Route.serializer(),
|
||||
override val koin: Koin = ru.shadowsparky.koin
|
||||
) : RootComponent<Route>(componentContext), WebNavigationOwner {
|
||||
val updateComponent = updateComponentFactory.create(childContext("UpdateComponentRoot"))
|
||||
private val scope = createComponentScope()
|
||||
val isLoggedIn = tokenStorage.token.map {
|
||||
if (it != null) {
|
||||
runCatching { healthCheck.check() }.getOrNull() ?: return@map false
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
scope.launch {
|
||||
repeatOnLifecycle {
|
||||
tokenStorage.token.collect {
|
||||
if (it != null) {
|
||||
val invalid = runCatching { healthCheck.check() }.getOrNull() == null
|
||||
if (invalid) { navReplace(initRoute) }
|
||||
}
|
||||
} // i love you
|
||||
}
|
||||
}
|
||||
scope.launch {
|
||||
repeatOnLifecycle {
|
||||
tokenStorage.token.flatMapLatest {
|
||||
@@ -103,7 +105,7 @@ class RootFactory(
|
||||
return VBoxRootComponent(
|
||||
context,
|
||||
tokenStorage,
|
||||
listOf(Route.Loading(next = initStack.toSet())),
|
||||
Route.Loading(next = initStack.toSet()),
|
||||
heathCheck,
|
||||
imageLoaderProvider,
|
||||
updateComponentFactory,
|
||||
|
||||
+10
-6
@@ -33,6 +33,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.text.selection.SelectionContainer
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
@@ -292,12 +293,15 @@ private fun OverviewDescription(
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
modifier = Modifier.padding(vertical = 8.dp)
|
||||
)
|
||||
Text(
|
||||
text = details.desc.trim(),
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
maxLines = if (showDetails.value) Int.MAX_VALUE else 3,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
|
||||
SelectionContainer {
|
||||
Text(
|
||||
text = details.desc.trim(),
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
maxLines = if (showDetails.value) Int.MAX_VALUE else 3,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
}
|
||||
|
||||
AnimatedVisibility(
|
||||
visible = !showDetails.value,
|
||||
|
||||
Reference in New Issue
Block a user