Make forceRefresh non-null

This commit is contained in:
maxmoney21m
2023-03-13 13:07:01 +08:00
parent bb7dcbdb78
commit e4cec20d1a
4 changed files with 7 additions and 7 deletions

View File

@ -45,7 +45,7 @@ sealed class Route(
hasNewItems = { accountViewModel, cache, context -> homeHasNewItems(accountViewModel, cache, context) }, hasNewItems = { accountViewModel, cache, context -> homeHasNewItems(accountViewModel, cache, context) },
buildScreen = { accountViewModel, _, navController -> buildScreen = { accountViewModel, _, navController ->
{ backStackEntry -> { backStackEntry ->
HomeScreen(accountViewModel, navController, backStackEntry.arguments?.getBoolean("forceRefresh", false)) HomeScreen(accountViewModel, navController, backStackEntry.arguments?.getBoolean("forceRefresh", false) ?: false)
} }
} }
) )
@ -56,7 +56,7 @@ sealed class Route(
arguments = listOf(navArgument("forceRefresh") { type = NavType.BoolType; defaultValue = false }), arguments = listOf(navArgument("forceRefresh") { type = NavType.BoolType; defaultValue = false }),
buildScreen = { acc, _, navController -> buildScreen = { acc, _, navController ->
{ backStackEntry -> { backStackEntry ->
SearchScreen(acc, navController, backStackEntry.arguments?.getBoolean("forceRefresh", false)) SearchScreen(acc, navController, backStackEntry.arguments?.getBoolean("forceRefresh", false) ?: false)
} }
} }
) )

View File

@ -42,11 +42,11 @@ fun FeedView(
navController: NavController, navController: NavController,
routeForLastRead: String?, routeForLastRead: String?,
scrollStateKey: String? = null, scrollStateKey: String? = null,
forceRefresh: Boolean? = false forceRefresh: Boolean = false
) { ) {
val feedState by viewModel.feedContent.collectAsState() val feedState by viewModel.feedContent.collectAsState()
var refreshing by remember { mutableStateOf(forceRefresh!!) } var refreshing by remember { mutableStateOf(forceRefresh) }
val refresh = { refreshing = true; viewModel.refresh(); refreshing = false } val refresh = { refreshing = true; viewModel.refresh(); refreshing = false }
val pullRefreshState = rememberPullRefreshState(refreshing, onRefresh = refresh) val pullRefreshState = rememberPullRefreshState(refreshing, onRefresh = refresh)
@ -77,7 +77,7 @@ fun FeedView(
accountViewModel, accountViewModel,
navController, navController,
scrollStateKey, scrollStateKey,
forceRefresh!! forceRefresh
) )
} }

View File

@ -39,7 +39,7 @@ import kotlinx.coroutines.launch
@OptIn(ExperimentalPagerApi::class) @OptIn(ExperimentalPagerApi::class)
@Composable @Composable
fun HomeScreen(accountViewModel: AccountViewModel, navController: NavController, forceRefresh: Boolean? = false) { fun HomeScreen(accountViewModel: AccountViewModel, navController: NavController, forceRefresh: Boolean = false) {
val accountState by accountViewModel.accountLiveData.observeAsState() val accountState by accountViewModel.accountLiveData.observeAsState()
val account = accountState?.account ?: return val account = accountState?.account ?: return

View File

@ -79,7 +79,7 @@ import kotlinx.coroutines.withContext
import kotlinx.coroutines.channels.Channel as CoroutineChannel import kotlinx.coroutines.channels.Channel as CoroutineChannel
@Composable @Composable
fun SearchScreen(accountViewModel: AccountViewModel, navController: NavController, forceRefresh: Boolean? = false) { fun SearchScreen(accountViewModel: AccountViewModel, navController: NavController, forceRefresh: Boolean = false) {
val accountState by accountViewModel.accountLiveData.observeAsState() val accountState by accountViewModel.accountLiveData.observeAsState()
val account = accountState?.account ?: return val account = accountState?.account ?: return