Fix "more replies" link for unavailable tweets

This commit is contained in:
Zed 2019-09-24 16:01:09 +02:00
parent 7915616e2e
commit 7e713e8fa5
2 changed files with 8 additions and 2 deletions

View file

@ -131,6 +131,7 @@ proc getRfc822Time*(tweet: Tweet): string =
tweet.time.format("ddd', 'd MMM yyyy HH:mm:ss 'GMT'") tweet.time.format("ddd', 'd MMM yyyy HH:mm:ss 'GMT'")
proc getLink*(tweet: Tweet | Quote): string = proc getLink*(tweet: Tweet | Quote): string =
if tweet.id.len == 0: return
&"/{tweet.profile.username}/status/{tweet.id}" &"/{tweet.profile.username}/status/{tweet.id}"
proc getTombstone*(text: string): string = proc getTombstone*(text: string): string =

View file

@ -6,9 +6,14 @@ import tweet, timeline
proc renderMoreReplies(thread: Thread): VNode = proc renderMoreReplies(thread: Thread): VNode =
let num = if thread.more != -1: $thread.more & " " else: "" let num = if thread.more != -1: $thread.more & " " else: ""
let reply = if thread.more == 1: "reply" else: "replies" let reply = if thread.more == 1: "reply" else: "replies"
let link = getLink(thread.content[0])
buildHtml(tdiv(class="timeline-item more-replies")): buildHtml(tdiv(class="timeline-item more-replies")):
a(class="more-replies-text", href=getLink(thread.content[0])): if link.len > 0:
text $num & "more " & reply a(class="more-replies-text", href=getLink(thread.content[0])):
text $num & "more " & reply
else:
a(class="more-replies-text"):
text $num & "more " & reply
proc renderReplyThread(thread: Thread; prefs: Prefs; path: string): VNode = proc renderReplyThread(thread: Thread; prefs: Prefs; path: string): VNode =
buildHtml(tdiv(class="reply thread thread-line")): buildHtml(tdiv(class="reply thread thread-line")):