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

View file

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

View file

@ -3,6 +3,6 @@
<ManuallySuppressedIssues></ManuallySuppressedIssues>
<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>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>
</SmellBaseline>