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

View File

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