chore: rename paging-related parameters and variables

This commit is contained in:
Harsh Shandilya 2022-11-27 20:02:51 +05:30
parent d59a151944
commit a03ff1a60b
No known key found for this signature in database
3 changed files with 9 additions and 9 deletions

View file

@ -171,7 +171,7 @@ fun LobstersApp(
) { ) {
setWebUri("https://lobste.rs/") setWebUri("https://lobste.rs/")
NetworkPosts( NetworkPosts(
items = hottestPosts, lazyPagingItems = hottestPosts,
listState = hottestListState, listState = hottestListState,
isPostSaved = viewModel::isPostSaved, isPostSaved = viewModel::isPostSaved,
reloadPosts = viewModel::refreshHottestPosts, reloadPosts = viewModel::refreshHottestPosts,
@ -183,7 +183,7 @@ fun LobstersApp(
) { ) {
setWebUri("https://lobste.rs/") setWebUri("https://lobste.rs/")
NetworkPosts( NetworkPosts(
items = newestPosts, lazyPagingItems = newestPosts,
listState = newestListState, listState = newestListState,
isPostSaved = viewModel::isPostSaved, isPostSaved = viewModel::isPostSaved,
reloadPosts = viewModel::refreshNewestPosts, reloadPosts = viewModel::refreshNewestPosts,

View file

@ -32,28 +32,28 @@ import dev.msfjarvis.claw.model.LobstersPost
@OptIn(ExperimentalMaterialApi::class) @OptIn(ExperimentalMaterialApi::class)
@Composable @Composable
fun NetworkPosts( fun NetworkPosts(
items: LazyPagingItems<LobstersPost>, lazyPagingItems: LazyPagingItems<LobstersPost>,
listState: LazyListState, listState: LazyListState,
isPostSaved: suspend (SavedPost) -> Boolean, isPostSaved: suspend (SavedPost) -> Boolean,
reloadPosts: () -> Unit, reloadPosts: () -> Unit,
postActions: PostActions, postActions: PostActions,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
) { ) {
val loadState = items.loadState.refresh val refreshLoadState = lazyPagingItems.loadState.refresh
val isRefreshing = loadState == LoadState.Loading val isRefreshing = refreshLoadState == LoadState.Loading
val pullRefreshState = rememberPullRefreshState(isRefreshing, reloadPosts) val pullRefreshState = rememberPullRefreshState(isRefreshing, reloadPosts)
Box(modifier = modifier.fillMaxSize().pullRefresh(pullRefreshState)) { Box(modifier = modifier.fillMaxSize().pullRefresh(pullRefreshState)) {
if (items.itemCount == 0 && loadState is LoadState.Error) { if (lazyPagingItems.itemCount == 0 && refreshLoadState is LoadState.Error) {
NetworkError( NetworkError(
label = "Failed to load posts", label = "Failed to load posts",
error = loadState.error, error = refreshLoadState.error,
modifier = Modifier.align(Alignment.Center), modifier = Modifier.align(Alignment.Center),
) )
} else { } else {
LazyColumn( LazyColumn(
state = listState, state = listState,
) { ) {
items(items) { item -> items(lazyPagingItems) { item ->
if (item != null) { if (item != null) {
val dbModel = item.toDbModel() val dbModel = item.toDbModel()
ListItem( ListItem(

View file

@ -3,6 +3,6 @@
<ManuallySuppressedIssues></ManuallySuppressedIssues> <ManuallySuppressedIssues></ManuallySuppressedIssues>
<CurrentIssues> <CurrentIssues>
<ID>LongMethod:LobstersApp.kt$@OptIn(ExperimentalMaterial3Api::class) @Composable fun LobstersApp( urlLauncher: UrlLauncher, htmlConverter: HTMLConverter, setWebUri: (String?) -&gt; Unit, modifier: Modifier = Modifier, viewModel: ClawViewModel = injectedViewModel(), )</ID> <ID>LongMethod:LobstersApp.kt$@OptIn(ExperimentalMaterial3Api::class) @Composable fun LobstersApp( urlLauncher: UrlLauncher, htmlConverter: HTMLConverter, setWebUri: (String?) -&gt; Unit, modifier: Modifier = Modifier, viewModel: ClawViewModel = injectedViewModel(), )</ID>
<ID>LongParameterList:NetworkPosts.kt$( items: LazyPagingItems&lt;LobstersPost&gt;, listState: LazyListState, isPostSaved: suspend (SavedPost) -&gt; Boolean, reloadPosts: () -&gt; Unit, postActions: PostActions, modifier: Modifier = Modifier, )</ID> <ID>LongParameterList:NetworkPosts.kt$( lazyPagingItems: LazyPagingItems&lt;LobstersPost&gt;, listState: LazyListState, isPostSaved: suspend (SavedPost) -&gt; Boolean, reloadPosts: () -&gt; Unit, postActions: PostActions, modifier: Modifier = Modifier, )</ID>
</CurrentIssues> </CurrentIssues>
</SmellBaseline> </SmellBaseline>