fix: 楼中楼无法加载更多
This commit is contained in:
parent
b2edec39eb
commit
23009f1da3
|
|
@ -173,9 +173,13 @@ internal fun SubPostsContent(
|
||||||
prop1 = SubPostsUiState::currentPage,
|
prop1 = SubPostsUiState::currentPage,
|
||||||
initial = 1
|
initial = 1
|
||||||
)
|
)
|
||||||
|
val totalCount by viewModel.uiState.collectPartialAsState(
|
||||||
|
prop1 = SubPostsUiState::totalCount,
|
||||||
|
initial = 0
|
||||||
|
)
|
||||||
val hasMore by viewModel.uiState.collectPartialAsState(
|
val hasMore by viewModel.uiState.collectPartialAsState(
|
||||||
prop1 = SubPostsUiState::hasMore,
|
prop1 = SubPostsUiState::hasMore,
|
||||||
initial = false
|
initial = true
|
||||||
)
|
)
|
||||||
|
|
||||||
val lazyListState = rememberLazyListState()
|
val lazyListState = rememberLazyListState()
|
||||||
|
|
@ -330,7 +334,7 @@ internal fun SubPostsContent(
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(
|
text = stringResource(
|
||||||
id = R.string.title_sub_posts_header,
|
id = R.string.title_sub_posts_header,
|
||||||
subPosts.size
|
totalCount
|
||||||
),
|
),
|
||||||
style = MaterialTheme.typography.subtitle1
|
style = MaterialTheme.typography.subtitle1
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -74,9 +74,10 @@ class SubPostsViewModel @Inject constructor() :
|
||||||
post.contentRenders,
|
post.contentRenders,
|
||||||
subPosts.wrapImmutable(),
|
subPosts.wrapImmutable(),
|
||||||
subPosts.map { it.content.renders }.toImmutableList(),
|
subPosts.map { it.content.renders }.toImmutableList(),
|
||||||
page.has_more == 1,
|
page.current_page < page.total_page,
|
||||||
page.current_page,
|
page.current_page,
|
||||||
page.total_page
|
page.total_page,
|
||||||
|
page.total_count
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.onStart { emit(SubPostsPartialChange.Load.Start) }
|
.onStart { emit(SubPostsPartialChange.Load.Start) }
|
||||||
|
|
@ -92,8 +93,10 @@ class SubPostsViewModel @Inject constructor() :
|
||||||
SubPostsPartialChange.LoadMore.Success(
|
SubPostsPartialChange.LoadMore.Success(
|
||||||
subPosts.wrapImmutable(),
|
subPosts.wrapImmutable(),
|
||||||
subPosts.map { it.content.renders }.toImmutableList(),
|
subPosts.map { it.content.renders }.toImmutableList(),
|
||||||
page.has_more == 1,
|
page.current_page < page.total_page,
|
||||||
page.current_page
|
page.current_page,
|
||||||
|
page.total_page,
|
||||||
|
page.total_count,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.onStart { emit(SubPostsPartialChange.LoadMore.Start) }
|
.onStart { emit(SubPostsPartialChange.LoadMore.Start) }
|
||||||
|
|
@ -155,6 +158,7 @@ sealed interface SubPostsPartialChange : PartialChange<SubPostsUiState> {
|
||||||
hasMore = hasMore,
|
hasMore = hasMore,
|
||||||
currentPage = currentPage,
|
currentPage = currentPage,
|
||||||
totalPage = totalPage,
|
totalPage = totalPage,
|
||||||
|
totalCount = totalCount,
|
||||||
forum = forum,
|
forum = forum,
|
||||||
post = post,
|
post = post,
|
||||||
postContentRenders = postContentRenders,
|
postContentRenders = postContentRenders,
|
||||||
|
|
@ -177,6 +181,7 @@ sealed interface SubPostsPartialChange : PartialChange<SubPostsUiState> {
|
||||||
val hasMore: Boolean,
|
val hasMore: Boolean,
|
||||||
val currentPage: Int,
|
val currentPage: Int,
|
||||||
val totalPage: Int,
|
val totalPage: Int,
|
||||||
|
val totalCount: Int,
|
||||||
) : Load()
|
) : Load()
|
||||||
|
|
||||||
data class Failure(val throwable: Throwable) : Load()
|
data class Failure(val throwable: Throwable) : Load()
|
||||||
|
|
@ -193,6 +198,8 @@ sealed interface SubPostsPartialChange : PartialChange<SubPostsUiState> {
|
||||||
isLoading = false,
|
isLoading = false,
|
||||||
hasMore = hasMore,
|
hasMore = hasMore,
|
||||||
currentPage = currentPage,
|
currentPage = currentPage,
|
||||||
|
totalPage = totalPage,
|
||||||
|
totalCount = totalCount,
|
||||||
subPosts = (oldState.subPosts + subPosts).toImmutableList(),
|
subPosts = (oldState.subPosts + subPosts).toImmutableList(),
|
||||||
subPostsContentRenders = (oldState.subPostsContentRenders + subPostsContentRenders).toImmutableList(),
|
subPostsContentRenders = (oldState.subPostsContentRenders + subPostsContentRenders).toImmutableList(),
|
||||||
)
|
)
|
||||||
|
|
@ -208,6 +215,8 @@ sealed interface SubPostsPartialChange : PartialChange<SubPostsUiState> {
|
||||||
val subPostsContentRenders: ImmutableList<ImmutableList<PbContentRender>>,
|
val subPostsContentRenders: ImmutableList<ImmutableList<PbContentRender>>,
|
||||||
val hasMore: Boolean,
|
val hasMore: Boolean,
|
||||||
val currentPage: Int,
|
val currentPage: Int,
|
||||||
|
val totalPage: Int,
|
||||||
|
val totalCount: Int,
|
||||||
) : LoadMore()
|
) : LoadMore()
|
||||||
|
|
||||||
data class Failure(val throwable: Throwable) : LoadMore()
|
data class Failure(val throwable: Throwable) : LoadMore()
|
||||||
|
|
@ -287,6 +296,7 @@ data class SubPostsUiState(
|
||||||
val hasMore: Boolean = true,
|
val hasMore: Boolean = true,
|
||||||
val currentPage: Int = 1,
|
val currentPage: Int = 1,
|
||||||
val totalPage: Int = 1,
|
val totalPage: Int = 1,
|
||||||
|
val totalCount: Int = 0,
|
||||||
|
|
||||||
val forum: ImmutableHolder<SimpleForum>? = null,
|
val forum: ImmutableHolder<SimpleForum>? = null,
|
||||||
val post: ImmutableHolder<Post>? = null,
|
val post: ImmutableHolder<Post>? = null,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue