From 397471f8f451876369f22a505831dc41890ba80d Mon Sep 17 00:00:00 2001 From: Zed Date: Fri, 6 Dec 2019 06:03:50 +0100 Subject: [PATCH] Add button to show earlier thread replies --- src/parser.nim | 5 +++++ src/sass/tweet/thread.scss | 5 +++++ src/views/status.nim | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/src/parser.nim b/src/parser.nim index 5bc4e7c..c9fe1d0 100644 --- a/src/parser.nim +++ b/src/parser.nim @@ -160,6 +160,11 @@ proc parseConversation*(node: XmlNode; after: string): Conversation = ) ) + if result.before != nil: + let maxId = node.selectAttr(".in-reply-to .stream-container", "data-max-position") + if maxId.len > 0: + result.before.more = -1 + let showMore = node.selectAttr(".ThreadedConversation-showMoreThreads button", "data-cursor") diff --git a/src/sass/tweet/thread.scss b/src/sass/tweet/thread.scss index c70fe80..f854eda 100644 --- a/src/sass/tweet/thread.scss +++ b/src/sass/tweet/thread.scss @@ -80,6 +80,11 @@ margin-bottom: 0; margin-left: -2.5px; } + + .earlier-replies { + padding-bottom: 0; + margin-bottom: -5px; + } } .timeline-item.thread-last::before { diff --git a/src/views/status.nim b/src/views/status.nim index a832e33..81311e2 100644 --- a/src/views/status.nim +++ b/src/views/status.nim @@ -3,6 +3,11 @@ import karax/[karaxdsl, vdom] import ".."/[types, formatters] import tweet, timeline +proc renderEarlier(thread: Chain): VNode = + buildHtml(tdiv(class="timeline-item more-replies earlier-replies")): + a(class="more-replies-text", href=getLink(thread.content[0])): + text "earlier replies" + proc renderMoreReplies(thread: Chain): VNode = let num = if thread.more != -1: $thread.more & " " else: "" let reply = if thread.more == 1: "reply" else: "replies" @@ -31,6 +36,8 @@ proc renderConversation*(conversation: Conversation; prefs: Prefs; path: string) tdiv(class="main-thread"): if conversation.before != nil: tdiv(class="before-tweet thread-line"): + if conversation.before.more == -1: + renderEarlier(conversation.before) for i, tweet in conversation.before.content: renderTweet(tweet, prefs, path, index=i)