Show related tweets under replies

Fixes #1334
This commit is contained in:
Zed 2026-07-11 00:11:46 +02:00
commit 092397cd6f
6 changed files with 46 additions and 3 deletions

View file

@ -710,10 +710,26 @@ proc parseGraphTweet*(js: JsonNode): Tweet =
with birdwatch, js{"birdwatch_pivot"}:
result.note = parseCommunityNote(birdwatch)
proc getConvSection(js: JsonNode): string =
let details = select(
js{"item", "client_event_info", "details"},
js{"item", "clientEventInfo", "details"}
)
select(
details{"conversation_details", "conversation_section"},
details{"conversationDetails", "conversationSection"}
).getStr
proc parseGraphThread(js: JsonNode): tuple[thread: Chain; self: bool] =
var checkedSection = false
for t in ? js{"content", "items"}:
let entryId = t.getEntryId
if "tweet-" in entryId and "promoted" notin entryId:
if not checkedSection:
checkedSection = true
if getConvSection(t) == "RelatedTweet":
result.thread.related = true
let tweet = t.getTweetResult("item")
if tweet.notNull:
result.thread.content.add parseGraphTweet(tweet)
@ -774,7 +790,8 @@ proc parseGraphConversation*(js: JsonNode; tweetId: string): Conversation =
result.before.content.add tweet
elif not entryId.endsWith(tweetId):
result.before.content.add Tweet(id: entryId.getId)
elif entryId.startsWith("conversationthread"):
elif entryId.startsWith("conversationthread") or
entryId.startsWith("tweetdetailrelatedtweets"):
let (thread, self) = parseGraphThread(e)
if self:
result.after = thread