Fix Spotless

pull/1461/head
TM 1 year ago
parent 79687cca56
commit ee5c29f805

@ -110,7 +110,7 @@ fun NiaApp(appState: NiaAppState, modifier: Modifier = Modifier) {
val snackBarResult = snackbarHostState.showSnackbar( val snackBarResult = snackbarHostState.showSnackbar(
message = it, message = it,
actionLabel = "Continue", actionLabel = "Continue",
duration = Indefinite duration = Indefinite,
) == ActionPerformed ) == ActionPerformed
if (snackBarResult) { if (snackBarResult) {
@ -232,7 +232,7 @@ internal fun NiaApp(
duration = Short, duration = Short,
) == ActionPerformed ) == ActionPerformed
}, },
errorHandler = { message -> appState.addErrorMessage(message) } errorHandler = { message -> appState.addErrorMessage(message) },
) )
} }
} }

@ -46,14 +46,11 @@ import com.google.samples.apps.nowinandroid.navigation.TopLevelDestination.BOOKM
import com.google.samples.apps.nowinandroid.navigation.TopLevelDestination.FOR_YOU import com.google.samples.apps.nowinandroid.navigation.TopLevelDestination.FOR_YOU
import com.google.samples.apps.nowinandroid.navigation.TopLevelDestination.INTERESTS import com.google.samples.apps.nowinandroid.navigation.TopLevelDestination.INTERESTS
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.update import kotlinx.coroutines.flow.update
import kotlinx.datetime.TimeZone import kotlinx.datetime.TimeZone
@ -123,18 +120,18 @@ class NiaAppState(
initialValue = false, initialValue = false,
) )
private val _errorMessages = MutableStateFlow<List<ErrorMessage>>(emptyList()) private val errorMessages = MutableStateFlow<List<ErrorMessage>>(emptyList())
val errorMessage: StateFlow<String?> = _errorMessages.map{ it.firstOrNull()?.message }.stateIn( val errorMessage: StateFlow<String?> = errorMessages.map { it.firstOrNull()?.message }.stateIn(
scope = coroutineScope, scope = coroutineScope,
started = SharingStarted.WhileSubscribed(5_000), started = SharingStarted.WhileSubscribed(5_000),
initialValue = null, initialValue = null,
) )
fun addErrorMessage(error: String) { fun addErrorMessage(error: String) {
_errorMessages.update { it + ErrorMessage(error) } errorMessages.update { it + ErrorMessage(error) }
} }
fun clearErrorMessage() { fun clearErrorMessage() {
_errorMessages.update { it.drop(1) } errorMessages.update { it.drop(1) }
} }
/** /**

@ -478,6 +478,7 @@ private fun DeepLinkEffect(
context = context, context = context,
uri = Uri.parse(userNewsResource.url), uri = Uri.parse(userNewsResource.url),
toolbarColor = backgroundColor, toolbarColor = backgroundColor,
onLaunchFailed = {},
) )
} }
} }

@ -123,7 +123,7 @@ internal fun SearchRoute(
onBackClick = onBackClick, onBackClick = onBackClick,
onInterestsClick = onInterestsClick, onInterestsClick = onInterestsClick,
onTopicClick = onTopicClick, onTopicClick = onTopicClick,
onLaunchFailed = { errorHandler(launchFailedString) }, onLaunchFailed = { errorHandler(launchFailedString) },
) )
} }
@ -371,7 +371,7 @@ private fun SearchResultBody(
}, },
onLaunchFailed = { onLaunchFailed = {
onLaunchFailed() onLaunchFailed()
} },
) )
} }
} }

@ -39,7 +39,7 @@ fun NavGraphBuilder.searchScreen(
onBackClick = onBackClick, onBackClick = onBackClick,
onInterestsClick = onInterestsClick, onInterestsClick = onInterestsClick,
onTopicClick = onTopicClick, onTopicClick = onTopicClick,
errorHandler = errorHandler errorHandler = errorHandler,
) )
} }
} }

Loading…
Cancel
Save