fix: 贴子页面回复后闪退
This commit is contained in:
parent
ea5c39e7e4
commit
895e6a8e55
|
|
@ -309,8 +309,6 @@ class ThreadViewModel @Inject constructor() :
|
||||||
ThreadPartialChange.LoadLatestReply.Success(
|
ThreadPartialChange.LoadLatestReply.Success(
|
||||||
anti = response.data_.anti,
|
anti = response.data_.anti,
|
||||||
posts = response.data_.post_list.map { PostItemData(it.wrapImmutable()) },
|
posts = response.data_.post_list.map { PostItemData(it.wrapImmutable()) },
|
||||||
contentRenders = response.data_.post_list.map { it.contentRenders },
|
|
||||||
subPostContents = response.data_.post_list.map { it.subPostContents },
|
|
||||||
page = response.data_.page.current_page,
|
page = response.data_.page.current_page,
|
||||||
isContinuous = firstLatestPost.floor == curLatestPostFloor + 1,
|
isContinuous = firstLatestPost.floor == curLatestPostFloor + 1,
|
||||||
isDesc = isDesc,
|
isDesc = isDesc,
|
||||||
|
|
@ -805,6 +803,9 @@ sealed interface ThreadPartialChange : PartialChange<ThreadUiState> {
|
||||||
val replaceIndex = replacePostIndexes.firstOrNull { it.first == index }
|
val replaceIndex = replacePostIndexes.firstOrNull { it.first == index }
|
||||||
if (replaceIndex != null) posts[replaceIndex.second] else oldItem
|
if (replaceIndex != null) posts[replaceIndex.second] else oldItem
|
||||||
}
|
}
|
||||||
|
val addPosts = posts.filter {
|
||||||
|
!newPost.any { item -> item.post.get { id } == it.post.get { id } }
|
||||||
|
}
|
||||||
when {
|
when {
|
||||||
hasNewPost && continuous && isDesc -> {
|
hasNewPost && continuous && isDesc -> {
|
||||||
oldState.copy(
|
oldState.copy(
|
||||||
|
|
@ -812,7 +813,7 @@ sealed interface ThreadPartialChange : PartialChange<ThreadUiState> {
|
||||||
isError = false,
|
isError = false,
|
||||||
error = null,
|
error = null,
|
||||||
anti = anti.wrapImmutable(),
|
anti = anti.wrapImmutable(),
|
||||||
data = (posts + newPost).toImmutableList(),
|
data = (addPosts.reversed() + newPost).toImmutableList(),
|
||||||
latestPosts = persistentListOf(),
|
latestPosts = persistentListOf(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -823,7 +824,7 @@ sealed interface ThreadPartialChange : PartialChange<ThreadUiState> {
|
||||||
isError = false,
|
isError = false,
|
||||||
error = null,
|
error = null,
|
||||||
anti = anti.wrapImmutable(),
|
anti = anti.wrapImmutable(),
|
||||||
data = (newPost + posts).toImmutableList(),
|
data = (newPost + addPosts).toImmutableList(),
|
||||||
latestPosts = persistentListOf(),
|
latestPosts = persistentListOf(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -872,8 +873,6 @@ sealed interface ThreadPartialChange : PartialChange<ThreadUiState> {
|
||||||
data class Success(
|
data class Success(
|
||||||
val anti: Anti,
|
val anti: Anti,
|
||||||
val posts: List<PostItemData>,
|
val posts: List<PostItemData>,
|
||||||
val contentRenders: List<ImmutableList<PbContentRender>>,
|
|
||||||
val subPostContents: List<ImmutableList<AnnotatedString>>,
|
|
||||||
val page: Int,
|
val page: Int,
|
||||||
val isContinuous: Boolean,
|
val isContinuous: Boolean,
|
||||||
val isDesc: Boolean,
|
val isDesc: Boolean,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue