Add pref to hide tweet replies
This commit is contained in:
parent
0f43d37c9e
commit
25a6590a56
|
@ -28,6 +28,7 @@ withDb:
|
||||||
discard
|
discard
|
||||||
Prefs.theme.safeAddColumn
|
Prefs.theme.safeAddColumn
|
||||||
Prefs.hidePins.safeAddColumn
|
Prefs.hidePins.safeAddColumn
|
||||||
|
Prefs.hideReplies.safeAddColumn
|
||||||
|
|
||||||
proc getDefaultPrefs(cfg: Config): Prefs =
|
proc getDefaultPrefs(cfg: Config): Prefs =
|
||||||
result = genDefaultPrefs()
|
result = genDefaultPrefs()
|
||||||
|
|
|
@ -68,6 +68,10 @@ const prefList*: OrderedTable[string, seq[Pref]] = {
|
||||||
Pref(kind: checkbox, name: "hidePins",
|
Pref(kind: checkbox, name: "hidePins",
|
||||||
label: "Hide pinned tweets",
|
label: "Hide pinned tweets",
|
||||||
defaultState: false),
|
defaultState: false),
|
||||||
|
|
||||||
|
Pref(kind: checkbox, name: "hideReplies",
|
||||||
|
label: "Hide tweet replies",
|
||||||
|
defaultState: false)
|
||||||
]
|
]
|
||||||
}.toOrderedTable
|
}.toOrderedTable
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ proc renderReplyThread(thread: Chain; prefs: Prefs; path: string): VNode =
|
||||||
|
|
||||||
proc renderConversation*(conversation: Conversation; prefs: Prefs; path: string): VNode =
|
proc renderConversation*(conversation: Conversation; prefs: Prefs; path: string): VNode =
|
||||||
let hasAfter = conversation.after != nil
|
let hasAfter = conversation.after != nil
|
||||||
|
let showReplies = not prefs.hideReplies
|
||||||
buildHtml(tdiv(class="conversation")):
|
buildHtml(tdiv(class="conversation")):
|
||||||
tdiv(class="main-thread"):
|
tdiv(class="main-thread"):
|
||||||
if conversation.before != nil:
|
if conversation.before != nil:
|
||||||
|
@ -48,14 +49,14 @@ proc renderConversation*(conversation: Conversation; prefs: Prefs; path: string)
|
||||||
if more != 0:
|
if more != 0:
|
||||||
renderMoreReplies(conversation.after)
|
renderMoreReplies(conversation.after)
|
||||||
|
|
||||||
if not conversation.replies.beginning:
|
if not conversation.replies.beginning and showReplies:
|
||||||
renderNewer(Query(), getLink(conversation.tweet))
|
renderNewer(Query(), getLink(conversation.tweet))
|
||||||
|
|
||||||
if conversation.replies.content.len > 0:
|
if conversation.replies.content.len > 0 and showReplies:
|
||||||
tdiv(class="replies", id="r"):
|
tdiv(class="replies", id="r"):
|
||||||
for thread in conversation.replies.content:
|
for thread in conversation.replies.content:
|
||||||
if thread == nil: continue
|
if thread == nil: continue
|
||||||
renderReplyThread(thread, prefs, path)
|
renderReplyThread(thread, prefs, path)
|
||||||
|
|
||||||
if conversation.replies.hasMore:
|
if conversation.replies.hasMore and showReplies:
|
||||||
renderMore(Query(), conversation.replies.minId, focus="#r")
|
renderMore(Query(), conversation.replies.minId, focus="#r")
|
||||||
|
|
Loading…
Reference in New Issue