fix: 吧页面点赞导致全部贴子点赞状态被更新

This commit is contained in:
HuanCheng65 2023-09-23 11:16:41 +08:00
parent 36bff0712f
commit c4e96c4031
No known key found for this signature in database
GPG Key ID: 5EC9DD60A32C7360
1 changed files with 6 additions and 6 deletions

View File

@ -255,7 +255,7 @@ sealed interface ForumThreadListPartialChange : PartialChange<ForumThreadListUiS
is Failure -> oldState.copy(isRefreshing = false) is Failure -> oldState.copy(isRefreshing = false)
} }
object Start : FirstLoad() data object Start : FirstLoad()
data class Success( data class Success(
val threadList: List<ThreadItemData>, val threadList: List<ThreadItemData>,
@ -287,7 +287,7 @@ sealed interface ForumThreadListPartialChange : PartialChange<ForumThreadListUiS
is Failure -> oldState.copy(isRefreshing = false) is Failure -> oldState.copy(isRefreshing = false)
} }
object Start : Refresh() data object Start : Refresh()
data class Success( data class Success(
val threadList: List<ThreadItemData>, val threadList: List<ThreadItemData>,
@ -317,7 +317,7 @@ sealed interface ForumThreadListPartialChange : PartialChange<ForumThreadListUiS
is Failure -> oldState.copy(isLoadingMore = false) is Failure -> oldState.copy(isLoadingMore = false)
} }
object Start : LoadMore() data object Start : LoadMore()
data class Success( data class Success(
val threadList: List<ThreadItemData>, val threadList: List<ThreadItemData>,
@ -333,12 +333,12 @@ sealed interface ForumThreadListPartialChange : PartialChange<ForumThreadListUiS
sealed class Agree private constructor() : ForumThreadListPartialChange { sealed class Agree private constructor() : ForumThreadListPartialChange {
private fun List<ThreadItemData>.updateAgreeStatus( private fun List<ThreadItemData>.updateAgreeStatus(
id: Long, threadId: Long,
hasAgree: Int hasAgree: Int,
): ImmutableList<ThreadItemData> { ): ImmutableList<ThreadItemData> {
return map { data -> return map { data ->
val (thread) = data val (thread) = data
if (thread.get { id } == id) { if (thread.get { id } == threadId) {
ThreadItemData(thread.getImmutable { updateAgreeStatus(hasAgree) }) ThreadItemData(thread.getImmutable { updateAgreeStatus(hasAgree) })
} else data } else data
}.toImmutableList() }.toImmutableList()