فهرست منبع

Add button to show earlier thread replies

Zed 6 سال پیش
والد
کامیت
397471f8f4
3فایلهای تغییر یافته به همراه17 افزوده شده و 0 حذف شده
  1. 5 0
      src/parser.nim
  2. 5 0
      src/sass/tweet/thread.scss
  3. 7 0
      src/views/status.nim

+ 5 - 0
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")
 

+ 5 - 0
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 {

+ 7 - 0
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)