don't replace with initRoute if oldToken is null
This commit is contained in:
+5
-2
@@ -8,6 +8,7 @@ import com.arkivanov.decompose.router.webhistory.WebNavigation
|
||||
import com.arkivanov.decompose.router.webhistory.WebNavigationOwner
|
||||
import com.arkivanov.essenty.lifecycle.coroutines.repeatOnLifecycle
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.flow.firstOrNull
|
||||
import kotlinx.coroutines.flow.flatMapLatest
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -41,13 +42,15 @@ class VBoxRootComponent(
|
||||
init {
|
||||
scope.launch {
|
||||
repeatOnLifecycle {
|
||||
var oldToken = tokenStorage.token.firstOrNull()
|
||||
tokenStorage.token.collect {
|
||||
if (it != null) {
|
||||
val invalid = runCatching { healthCheck.check() }.getOrNull() == null
|
||||
if (invalid) { navReplace(initRoute) }
|
||||
} else {
|
||||
if (invalid) navReplace(initRoute)
|
||||
} else if (oldToken != null) {
|
||||
navReplace(initRoute)
|
||||
}
|
||||
oldToken = it
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+17
-6
@@ -3,9 +3,11 @@ package ru.shadowsparky.vbox.shared.presentation.overview.season
|
||||
import androiddev.apps.vbox.client.shared.generated.resources.Res
|
||||
import androiddev.apps.vbox.client.shared.generated.resources.retry
|
||||
import androiddev.apps.vbox.client.shared.generated.resources.seasons_overview
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -17,6 +19,7 @@ import androidx.compose.runtime.withFrameNanos
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.unit.dp
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
import ru.shadowsparky.ui.LocalBlurState
|
||||
import ru.shadowsparky.ui.applyBlurSource
|
||||
@@ -24,7 +27,6 @@ import ru.shadowsparky.ui.components.BackButton
|
||||
import ru.shadowsparky.ui.components.ErrorContent
|
||||
import ru.shadowsparky.ui.components.ExpressiveLazyColumn
|
||||
import ru.shadowsparky.ui.components.Loading
|
||||
import ru.shadowsparky.ui.components.TextPreference
|
||||
import ru.shadowsparky.ui.components.TopAppBar
|
||||
import ru.shadowsparky.ui.rememberBlurState
|
||||
import ru.shadowsparky.vbox.shared.domain.model.Season
|
||||
@@ -79,15 +81,14 @@ fun SeasonsInfo(
|
||||
content = {
|
||||
section {
|
||||
itemsIndexed(seasons) { index, season ->
|
||||
TextPreference(
|
||||
season.title,
|
||||
onClick = { onClick(season.id) },
|
||||
SeasonInfo(
|
||||
modifier = if (index == 0) {
|
||||
Modifier.focusRequester(requester)
|
||||
} else {
|
||||
Modifier
|
||||
}
|
||||
)
|
||||
},
|
||||
season.title
|
||||
) { onClick(season.id) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -100,3 +101,13 @@ fun SeasonsInfo(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SeasonInfo(modifier: Modifier, titleText: String, onClick: () -> Unit) {
|
||||
Text(
|
||||
titleText,
|
||||
modifier = modifier.fillMaxWidth()
|
||||
.clickable { onClick() }
|
||||
.padding(16.dp)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user