mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 14:07:05 +05:30
feat: show "Authored by" on posts when applicable
This commit is contained in:
parent
4ebb99bf7d
commit
b132410282
6 changed files with 18 additions and 1 deletions
|
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
|
||||
- Change submitter text to 'authored' when applicable
|
||||
|
||||
## [1.48.0] - 2024-06-05
|
||||
|
||||
### Added
|
||||
|
|
|
@ -32,6 +32,11 @@ object SearchConverter : Converter<ResponseBody, List<LobstersPost>> {
|
|||
val tags = elem.select("span.tags > a").map(Element::text)
|
||||
val (commentCount, commentsUrl) = getCommentsData(elem.select("span.comments_label"))
|
||||
val submitter = elem.select("div.byline > a.u-author").text()
|
||||
val userIsAuthor =
|
||||
(elem.select("div.byline > span").first()?.text() ?: "").contains(
|
||||
"authored",
|
||||
ignoreCase = true,
|
||||
)
|
||||
return LobstersPost(
|
||||
shortId = shortId,
|
||||
title = title,
|
||||
|
@ -43,6 +48,7 @@ object SearchConverter : Converter<ResponseBody, List<LobstersPost>> {
|
|||
// The value of these fields is irrelevant for our use case
|
||||
createdAt = "",
|
||||
description = "",
|
||||
userIsAuthor = userIsAuthor,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ class SearchApiTest {
|
|||
submitter = "xenodium",
|
||||
tags = listOf("ai", "emacs"),
|
||||
description = "",
|
||||
userIsAuthor = true,
|
||||
),
|
||||
LobstersPost(
|
||||
shortId = "astcqf",
|
||||
|
@ -52,6 +53,7 @@ class SearchApiTest {
|
|||
submitter = "asteroid",
|
||||
tags = listOf("ai"),
|
||||
description = "",
|
||||
userIsAuthor = false,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -133,7 +133,10 @@ fun PostDetails(
|
|||
TagRow(tags = post.tags.toImmutableList())
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Submitter(
|
||||
text = AnnotatedString("Submitted by ${post.submitter}"),
|
||||
text =
|
||||
AnnotatedString(
|
||||
"${if (post.userIsAuthor) "Authored" else "Submitted"} by ${post.submitter}"
|
||||
),
|
||||
avatarUrl = "https://lobste.rs/avatars/${post.submitter}-100.png",
|
||||
contentDescription = "User avatar for ${post.submitter}",
|
||||
)
|
||||
|
|
|
@ -29,5 +29,6 @@ class LobstersPost(
|
|||
val commentCount: Int,
|
||||
val commentsUrl: String,
|
||||
@SerialName("submitter_user") val submitter: String,
|
||||
@SerialName("user_is_author") val userIsAuthor: Boolean,
|
||||
val tags: List<String>,
|
||||
)
|
||||
|
|
|
@ -29,6 +29,7 @@ data class UIPost(
|
|||
val comments: List<Comment> = emptyList(),
|
||||
val isSaved: Boolean = false,
|
||||
val isRead: Boolean = false,
|
||||
val userIsAuthor: Boolean = false,
|
||||
) {
|
||||
@KonvertFrom(
|
||||
value = SavedPost::class,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue