mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-07-09 18:39:56 +02:00
Make forceRefresh non-null
This commit is contained in:
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -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
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user