fix: 消息列表重复加载导致闪退

This commit is contained in:
HuanCheng65 2023-10-04 01:29:57 +08:00
parent ae6607cdf1
commit 047ebe4f2c
No known key found for this signature in database
GPG Key ID: 5EC9DD60A32C7360
2 changed files with 44 additions and 36 deletions

View File

@ -21,60 +21,62 @@ class MessageListBean : BaseBean() {
val page: PageInfoBean? = null
val message: MessageBean? = null
fun getErrorCode() = Integer.valueOf(errorCode!!)
fun getErrorCode(): Int = Integer.valueOf(errorCode!!)
open class UserInfoBean {
val id: String? = null
val name: String? = null
data class UserInfoBean(
val id: String? = null,
val name: String? = null,
@SerializedName("name_show")
val nameShow: String? = null
val nameShow: String? = null,
@JsonAdapter(PortraitAdapter::class)
val portrait: String? = null
val portrait: String? = null,
)
}
class ReplyerInfoBean : UserInfoBean() {
data class ReplyerInfoBean(
val id: String? = null,
val name: String? = null,
@SerializedName("name_show")
val nameShow: String? = null,
@JsonAdapter(PortraitAdapter::class)
val portrait: String? = null,
@SerializedName("is_friend")
val isFriend: String? = null
val isFriend: String? = null,
@SerializedName("is_fans")
val isFans: String? = null
val isFans: String? = null,
)
}
class MessageInfoBean {
data class MessageInfoBean(
@SerializedName("is_floor")
val isFloor: String? = null
val title: String? = null
val content: String? = null
val isFloor: String? = null,
val title: String? = null,
val content: String? = null,
@SerializedName("quote_content")
val quoteContent: String? = null
val replyer: ReplyerInfoBean? = null
val quoteContent: String? = null,
val replyer: ReplyerInfoBean? = null,
@SerializedName("quote_user")
val quoteUser: UserInfoBean? = null
val quoteUser: UserInfoBean? = null,
@SerializedName("thread_id")
val threadId: String? = null
val threadId: String? = null,
@SerializedName("post_id")
val postId: String? = null
val time: String? = null
val postId: String? = null,
val time: String? = null,
@SerializedName("fname")
val forumName: String? = null
val forumName: String? = null,
@SerializedName("quote_pid")
val quotePid: String? = null
val quotePid: String? = null,
@SerializedName("thread_type")
val threadType: String? = null
val unread: String? = null
}
val threadType: String? = null,
val unread: String? = null,
)
class MessageBean {
@SerializedName("replyme")

View File

@ -146,12 +146,18 @@ sealed interface NotificationsListPartialChange : PartialChange<NotificationsLis
override fun reduce(oldState: NotificationsListUiState): NotificationsListUiState =
when (this) {
Start -> oldState.copy(isLoadingMore = true)
is Success -> oldState.copy(
isLoadingMore = false,
currentPage = currentPage,
data = (oldState.data + data).toImmutableList(),
hasMore = hasMore
)
is Success -> {
val uniqueData = data.filter { item ->
oldState.data.none { it.info == item.info }
}
oldState.copy(
isLoadingMore = false,
currentPage = currentPage,
data = (oldState.data + uniqueData).toImmutableList(),
hasMore = hasMore
)
}
is Failure -> oldState.copy(isLoadingMore = false)
}