diff --git a/src/api.nim b/src/api.nim index 150401c..876f683 100644 --- a/src/api.nim +++ b/src/api.nim @@ -110,6 +110,7 @@ proc getVideo*(tweet: Tweet; token: string) {.async.} = tokenUses.inc proc getVideos*(thread: Thread; token="") {.async.} = + if thread == nil: return var gToken = token if gToken.len == 0: @@ -150,6 +151,7 @@ proc getPoll*(tweet: Tweet) {.async.} = tweet.poll = some(parsePoll(html)) proc getPolls*(thread: Thread) {.async.} = + if thread == nil: return var polls = thread.tweets.filterIt(it.poll.isSome) await all(polls.map(getPoll)) diff --git a/src/parser.nim b/src/parser.nim index 0f6d06b..17f514e 100644 --- a/src/parser.nim +++ b/src/parser.nim @@ -88,6 +88,7 @@ proc parseTweet*(node: XmlNode): Tweet = proc parseThread*(nodes: XmlNode): Thread = if nodes == nil: return + result = Thread() for n in nodes.filterIt(it.kind != xnText): let class = n.attr("class").toLower() if "tombstone" in class or "unavailable" in class: diff --git a/src/types.nim b/src/types.nim index 639aee2..82b745b 100644 --- a/src/types.nim +++ b/src/types.nim @@ -91,7 +91,7 @@ type photos*: seq[string] poll*: Option[Poll] - Thread* = object + Thread* = ref object tweets*: seq[Tweet] more*: int diff --git a/src/views/user.nimf b/src/views/user.nimf index 0aec49d..e7ce059 100644 --- a/src/views/user.nimf +++ b/src/views/user.nimf @@ -104,7 +104,7 @@ #proc renderConversation*(conversation: Conversation): string =