新增评论回复功能

- 允许用户回复评论和子评论
- 点击回复按钮,弹出评论框,并显示回复的用户
- 评论
列表中显示回复的用户和内容
- 点击回复内容中的用户名,跳转到用户主页
- 优化评论列表加载逻辑,支持加载更多子评论
This commit is contained in:
2024-09-08 21:46:44 +08:00
parent 03a4db8a4b
commit 7c0d183571
16 changed files with 677 additions and 347 deletions

View File

@@ -19,7 +19,14 @@ data class CommentEntity(
val author: Long,
var liked: Boolean,
var unread: Boolean = false,
var post: NoticePost?
var post: NoticePost?,
var reply: List<CommentEntity>,
var replyUserId: Long?,
var replyUserNickname: String?,
var replyUserAvatar: String?,
var parentCommentId: Int?,
var replyCount: Int,
var replyPage: Int = 1
)
class CommentPagingSource(
@@ -27,7 +34,8 @@ class CommentPagingSource(
private val postId: Int? = null,
private val postUser: Int? = null,
private val selfNotice: Boolean? = null,
private val order: String? = null
private val order: String? = null,
private val parentCommentId: Int? = null
) : PagingSource<Int, CommentEntity>() {
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, CommentEntity> {
return try {
@@ -37,7 +45,8 @@ class CommentPagingSource(
postId = postId,
postUser = postUser,
selfNotice = selfNotice,
order = order
order = order,
parentCommentId = parentCommentId
)
LoadResult.Page(
data = comments.list,