Add client preferences

This commit is contained in:
Zed
2019-08-13 19:44:29 +02:00
parent c42b2893ff
commit 966b3d5d62
12 changed files with 329 additions and 82 deletions

View File

@@ -4,11 +4,11 @@ import karax/[karaxdsl, vdom]
import ../types
import tweet, renderutils
proc renderReplyThread(thread: Thread): VNode =
proc renderReplyThread(thread: Thread; prefs: Prefs): VNode =
buildHtml(tdiv(class="reply thread thread-line")):
for i, tweet in thread.tweets:
let last = (i == thread.tweets.high and thread.more == 0)
renderTweet(tweet, index=i, last=last)
renderTweet(tweet, prefs, index=i, last=last)
if thread.more != 0:
let num = if thread.more != -1: $thread.more & " " else: ""
@@ -17,26 +17,26 @@ proc renderReplyThread(thread: Thread): VNode =
a(class="more-replies-text", title="Not implemented yet"):
text $num & "more " & reply
proc renderConversation*(conversation: Conversation): VNode =
proc renderConversation*(conversation: Conversation; prefs: Prefs): VNode =
let hasAfter = conversation.after != nil
buildHtml(tdiv(class="conversation", id="posts")):
tdiv(class="main-thread"):
if conversation.before != nil:
tdiv(class="before-tweet thread-line"):
for i, tweet in conversation.before.tweets:
renderTweet(tweet, index=i)
renderTweet(tweet, prefs, index=i)
tdiv(class="main-tweet"):
let afterClass = if hasAfter: "thread thread-line" else: ""
renderTweet(conversation.tweet, class=afterClass)
renderTweet(conversation.tweet, prefs, class=afterClass)
if hasAfter:
tdiv(class="after-tweet thread-line"):
let total = conversation.after.tweets.high
for i, tweet in conversation.after.tweets:
renderTweet(tweet, index=i, total=total)
renderTweet(tweet, prefs, index=i, total=total)
if conversation.replies.len > 0:
tdiv(class="replies"):
for thread in conversation.replies:
renderReplyThread(thread)
renderReplyThread(thread, prefs)