Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ fun CommentsInfoItem.toComment() = Comment(
commentId = commentId,
commentText = commentText.content,
commentedTime = textualUploadDate,
commentedTimeMillis = uploadDate?.offsetDateTime()?.toEpochSecond()?.times(1000),
commentorUrl = uploaderUrl.toID(),
hearted = isHeartedByUploader,
creatorReplied = hasCreatorReply(),
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/github/libretube/api/obj/Comment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ data class Comment(
val commentId: String,
val commentText: String?,
val commentedTime: String,
// not part of Piped's API
val commentedTimeMillis: Long? = null,
val commentorUrl: String,
val repliesPage: String? = null,
val hearted: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import com.github.libretube.ui.fragments.CommentsRepliesFragment
import com.github.libretube.ui.viewholders.CommentsViewHolder
import com.github.libretube.util.HtmlParser
import com.github.libretube.util.LinkHandler
import com.github.libretube.util.TextUtils

class CommentPagingAdapter(
private val fragment: Fragment?,
Expand All @@ -37,10 +38,12 @@ class CommentPagingAdapter(
private val isRepliesAdapter: Boolean = false,
private val handleLink: ((url: String) -> Unit)?,
private val dismiss: () -> Unit
) : PagingDataAdapter<Comment, CommentsViewHolder>(DiffUtilItemCallback(
areItemsTheSame = { oldItem, newItem -> oldItem.commentId == newItem.commentId},
areContentsTheSame = { _, _ -> true },
)) {
) : PagingDataAdapter<Comment, CommentsViewHolder>(
DiffUtilItemCallback(
areItemsTheSame = { oldItem, newItem -> oldItem.commentId == newItem.commentId },
areContentsTheSame = { _, _ -> true },
)
) {
private var clickEventConsumedByLinkHandler = false

private fun navigateToReplies(comment: Comment) {
Expand Down Expand Up @@ -68,7 +71,9 @@ class CommentPagingAdapter(
commentAuthor.setBackgroundResource(
if (comment.channelOwner) R.drawable.comment_channel_owner_bg else 0
)
commentInfos.text = comment.commentedTime
comment.commentedTimeMillis?.let {
commentInfos.text = TextUtils.formatRelativeDate(it)
} ?: comment.commentedTime

commentText.movementMethod = LinkMovementMethodCompat.getInstance()
val linkHandler = LinkHandler {
Expand Down
Loading