Fix "Replying to" parsing

This commit is contained in:
Zed
2026-02-14 02:24:24 +01:00
parent 90b664ffb7
commit d45545cd53
2 changed files with 14 additions and 5 deletions

View File

@@ -283,7 +283,8 @@ proc parseCard(js: JsonNode; urls: JsonNode): Card =
result.url.len == 0 or result.url.startsWith("card://"):
result.url = getPicUrl(result.image)
proc parseTweet(js: JsonNode; jsCard: JsonNode = newJNull()): Tweet =
proc parseTweet(js: JsonNode; jsCard: JsonNode = newJNull();
replyId: int64 = 0): Tweet =
if js.isNull: return
let time =
@@ -307,6 +308,9 @@ proc parseTweet(js: JsonNode; jsCard: JsonNode = newJNull()): Tweet =
)
)
if result.replyId == 0:
result.replyId = replyId
# fix for pinned threads
if result.hasThread and result.threadId == 0:
result.threadId = js{"self_thread", "id_str"}.getId
@@ -402,12 +406,17 @@ proc parseGraphTweet(js: JsonNode): Tweet =
"binding_values": %bindingObj
}
result = parseTweet(js{"legacy"}, jsCard)
var replyId = 0
with restId, js{"reply_to_results", "rest_id"}:
replyId = restId.getId
result = parseTweet(js{"legacy"}, jsCard, replyId)
result.id = js{"rest_id"}.getId
result.user = parseGraphUser(js{"core"})
if result.replyId == 0:
result.replyId = js{"reply_to_results", "rest_id"}.getId
if result.reply.len == 0:
with replyTo, js{"reply_to_user_results", "result", "core", "screen_name"}:
result.reply = @[replyTo.getStr]
with count, js{"views", "count"}:
result.stats.views = count.getStr("0").parseInt

View File

@@ -307,7 +307,7 @@ proc renderTweet*(tweet: Tweet; prefs: Prefs; path: string; class=""; index=0;
renderHeader(tweet, retweet, pinned, prefs)
if not afterTweet and index == 0 and tweet.reply.len > 0 and
(tweet.reply.len > 1 or tweet.reply[0] != tweet.user.username):
(tweet.reply.len > 1 or tweet.reply[0] != tweet.user.username or pinned):
renderReply(tweet)
var tweetClass = "tweet-content media-body"