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

@ -50,7 +50,7 @@ proc renderHead*(prefs: Prefs; cfg: Config; req: Request; titleText=""; desc="";
let opensearchUrl = getUrlPrefix(cfg) & "/opensearch"
buildHtml(head):
link(rel="stylesheet", type="text/css", href="/css/style.css?v=50")
link(rel="stylesheet", type="text/css", href="/css/style.css?v=51")
link(rel="stylesheet", type="text/css", href="/css/fontello.css?v=7")
if theme.len > 0:

View file

@ -1,4 +1,5 @@
# SPDX-License-Identifier: AGPL-3.0-only
import sequtils
import karax/[karaxdsl, vdom]
import ".."/[types, formatters]
@ -48,7 +49,7 @@ proc renderReplies*(replies: Result[Chain]; prefs: Prefs; path: string;
var hasReplies = false
var replyCount = 0
for thread in replies.content:
if thread.content.len == 0: continue
if thread.content.len == 0 or thread.related: continue
hasReplies = true
replyCount += thread.content.len
renderReplyThread(thread, prefs, path)
@ -58,6 +59,14 @@ proc renderReplies*(replies: Result[Chain]; prefs: Prefs; path: string;
let extra = if sort == Relevance: "" else: "sort=" & $sort & "&"
renderMore(Query(), replies.bottom, focus="#r", extra=extra)
proc renderRelated(replies: Result[Chain]; prefs: Prefs; path: string): VNode =
buildHtml(tdiv(class="related-tweets")):
tdiv(class="related-header"):
text "Related tweets"
for thread in replies.content:
if thread.content.len == 0 or not thread.related: continue
renderReplyThread(thread, prefs, path)
proc renderConversation*(conv: Conversation; prefs: Prefs; path: string;
sort = Relevance): VNode =
let hasAfter = conv.after.content.len > 0
@ -95,6 +104,10 @@ proc renderConversation*(conv: Conversation; prefs: Prefs; path: string;
renderReplySort(sort)
renderReplies(conv.replies, prefs, path, conv.tweet, sort)
if not prefs.hideRelated:
if conv.replies.content.anyIt(it.related and it.content.len > 0):
renderRelated(conv.replies, prefs, path)
renderToTop(focus="#m")
proc renderEditHistory*(edits: EditHistory; prefs: Prefs; path: string): VNode =