diff --git a/app/src/main/java/com/huanchengfly/tieba/post/api/models/MessageListBean.kt b/app/src/main/java/com/huanchengfly/tieba/post/api/models/MessageListBean.kt index 0173cf97..7989ea01 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/api/models/MessageListBean.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/api/models/MessageListBean.kt @@ -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") diff --git a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/main/notifications/list/NotificationsListViewModel.kt b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/main/notifications/list/NotificationsListViewModel.kt index b046bf88..a75585d8 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/main/notifications/list/NotificationsListViewModel.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/main/notifications/list/NotificationsListViewModel.kt @@ -146,12 +146,18 @@ sealed interface NotificationsListPartialChange : PartialChange 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) }