mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-15 04:07:03 +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]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Change submitter text to 'authored' when applicable
|
||||||
|
|
||||||
## [1.48.0] - 2024-06-05
|
## [1.48.0] - 2024-06-05
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -32,6 +32,11 @@ object SearchConverter : Converter<ResponseBody, List<LobstersPost>> {
|
||||||
val tags = elem.select("span.tags > a").map(Element::text)
|
val tags = elem.select("span.tags > a").map(Element::text)
|
||||||
val (commentCount, commentsUrl) = getCommentsData(elem.select("span.comments_label"))
|
val (commentCount, commentsUrl) = getCommentsData(elem.select("span.comments_label"))
|
||||||
val submitter = elem.select("div.byline > a.u-author").text()
|
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(
|
return LobstersPost(
|
||||||
shortId = shortId,
|
shortId = shortId,
|
||||||
title = title,
|
title = title,
|
||||||
|
@ -43,6 +48,7 @@ object SearchConverter : Converter<ResponseBody, List<LobstersPost>> {
|
||||||
// The value of these fields is irrelevant for our use case
|
// The value of these fields is irrelevant for our use case
|
||||||
createdAt = "",
|
createdAt = "",
|
||||||
description = "",
|
description = "",
|
||||||
|
userIsAuthor = userIsAuthor,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ class SearchApiTest {
|
||||||
submitter = "xenodium",
|
submitter = "xenodium",
|
||||||
tags = listOf("ai", "emacs"),
|
tags = listOf("ai", "emacs"),
|
||||||
description = "",
|
description = "",
|
||||||
|
userIsAuthor = true,
|
||||||
),
|
),
|
||||||
LobstersPost(
|
LobstersPost(
|
||||||
shortId = "astcqf",
|
shortId = "astcqf",
|
||||||
|
@ -52,6 +53,7 @@ class SearchApiTest {
|
||||||
submitter = "asteroid",
|
submitter = "asteroid",
|
||||||
tags = listOf("ai"),
|
tags = listOf("ai"),
|
||||||
description = "",
|
description = "",
|
||||||
|
userIsAuthor = false,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,10 @@ fun PostDetails(
|
||||||
TagRow(tags = post.tags.toImmutableList())
|
TagRow(tags = post.tags.toImmutableList())
|
||||||
Spacer(Modifier.height(4.dp))
|
Spacer(Modifier.height(4.dp))
|
||||||
Submitter(
|
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",
|
avatarUrl = "https://lobste.rs/avatars/${post.submitter}-100.png",
|
||||||
contentDescription = "User avatar for ${post.submitter}",
|
contentDescription = "User avatar for ${post.submitter}",
|
||||||
)
|
)
|
||||||
|
|
|
@ -29,5 +29,6 @@ class LobstersPost(
|
||||||
val commentCount: Int,
|
val commentCount: Int,
|
||||||
val commentsUrl: String,
|
val commentsUrl: String,
|
||||||
@SerialName("submitter_user") val submitter: String,
|
@SerialName("submitter_user") val submitter: String,
|
||||||
|
@SerialName("user_is_author") val userIsAuthor: Boolean,
|
||||||
val tags: List<String>,
|
val tags: List<String>,
|
||||||
)
|
)
|
||||||
|
|
|
@ -29,6 +29,7 @@ data class UIPost(
|
||||||
val comments: List<Comment> = emptyList(),
|
val comments: List<Comment> = emptyList(),
|
||||||
val isSaved: Boolean = false,
|
val isSaved: Boolean = false,
|
||||||
val isRead: Boolean = false,
|
val isRead: Boolean = false,
|
||||||
|
val userIsAuthor: Boolean = false,
|
||||||
) {
|
) {
|
||||||
@KonvertFrom(
|
@KonvertFrom(
|
||||||
value = SavedPost::class,
|
value = SavedPost::class,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue