feat: reply notifications

This commit is contained in:
rebelonion 2024-02-27 02:13:06 -06:00
parent a8bd9ef97b
commit efe5f546a2
8 changed files with 316 additions and 71 deletions

View file

@ -119,7 +119,12 @@ class CommentsFragment : Fragment() {
binding.commentsList.layoutManager = LinearLayoutManager(activity)
lifecycleScope.launch {
loadAndDisplayComments()
val commentId = arguments?.getInt("commentId")
if (commentId != null && commentId > 0) {
loadSingleComment(commentId)
} else {
loadAndDisplayComments()
}
}
binding.commentSort.setOnClickListener { view ->
@ -395,6 +400,31 @@ class CommentsFragment : Fragment() {
adapter.add(section)
}
private suspend fun loadSingleComment(commentId: Int) {
binding.commentsProgressBar.visibility = View.VISIBLE
binding.commentsList.visibility = View.GONE
adapter.clear()
section.clear()
val comment = withContext(Dispatchers.IO) {
CommentsAPI.getSingleComment(commentId)
}
if (comment != null) {
withContext(Dispatchers.Main) {
section.add(
CommentItem(
comment,
buildMarkwon(),
section,
this@CommentsFragment,
backgroundColor,
0
)
)
}
}
}
private fun sortComments(comments: List<Comment>?): List<Comment> {
if (comments == null) return emptyList()
return when (PrefManager.getVal(PrefName.CommentSortOrder, "newest")) {