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
|
@ -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,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue