Add pref to hide tweet replies

This commit is contained in:
Zed 2019-10-29 18:33:50 +01:00
parent 0f43d37c9e
commit 25a6590a56
3 changed files with 9 additions and 3 deletions

View File

@ -28,6 +28,7 @@ withDb:
discard
Prefs.theme.safeAddColumn
Prefs.hidePins.safeAddColumn
Prefs.hideReplies.safeAddColumn
proc getDefaultPrefs(cfg: Config): Prefs =
result = genDefaultPrefs()

View File

@ -68,6 +68,10 @@ const prefList*: OrderedTable[string, seq[Pref]] = {
Pref(kind: checkbox, name: "hidePins",
label: "Hide pinned tweets",
defaultState: false),
Pref(kind: checkbox, name: "hideReplies",
label: "Hide tweet replies",
defaultState: false)
]
}.toOrderedTable

View File

@ -26,6 +26,7 @@ proc renderReplyThread(thread: Chain; prefs: Prefs; path: string): VNode =
proc renderConversation*(conversation: Conversation; prefs: Prefs; path: string): VNode =
let hasAfter = conversation.after != nil
let showReplies = not prefs.hideReplies
buildHtml(tdiv(class="conversation")):
tdiv(class="main-thread"):
if conversation.before != nil:
@ -48,14 +49,14 @@ proc renderConversation*(conversation: Conversation; prefs: Prefs; path: string)
if more != 0:
renderMoreReplies(conversation.after)
if not conversation.replies.beginning:
if not conversation.replies.beginning and showReplies:
renderNewer(Query(), getLink(conversation.tweet))
if conversation.replies.content.len > 0:
if conversation.replies.content.len > 0 and showReplies:
tdiv(class="replies", id="r"):
for thread in conversation.replies.content:
if thread == nil: continue
renderReplyThread(thread, prefs, path)
if conversation.replies.hasMore:
if conversation.replies.hasMore and showReplies:
renderMore(Query(), conversation.replies.minId, focus="#r")