Fix loading more tweets when last one is a retweet
This commit is contained in:
parent
2c2d2c767e
commit
8f7c61eab6
3 changed files with 6 additions and 3 deletions
|
@ -70,6 +70,7 @@ proc parseTweet*(tweet: XmlNode): Tweet =
|
||||||
let by = tweet.selectText(".js-retweet-text > a > b")
|
let by = tweet.selectText(".js-retweet-text > a > b")
|
||||||
if by.len > 0:
|
if by.len > 0:
|
||||||
result.retweetBy = some(by)
|
result.retweetBy = some(by)
|
||||||
|
result.retweetId = some(tweet.getAttr("data-retweet-id"))
|
||||||
|
|
||||||
proc parseTweets*(node: XmlNode): Tweets =
|
proc parseTweets*(node: XmlNode): Tweets =
|
||||||
if node.isNil: return
|
if node.isNil: return
|
||||||
|
|
|
@ -47,6 +47,7 @@ type
|
||||||
gif*: Option[string]
|
gif*: Option[string]
|
||||||
video*: Option[string]
|
video*: Option[string]
|
||||||
videoThumb*: Option[string]
|
videoThumb*: Option[string]
|
||||||
|
retweetId*: Option[string]
|
||||||
|
|
||||||
Tweets* = seq[Tweet]
|
Tweets* = seq[Tweet]
|
||||||
|
|
||||||
|
|
|
@ -72,14 +72,15 @@
|
||||||
#var retweets: Tweets
|
#var retweets: Tweets
|
||||||
#for tweet in tweets:
|
#for tweet in tweets:
|
||||||
#if tweet in retweets: continue
|
#if tweet in retweets: continue
|
||||||
#end if
|
#elif tweet.retweetBy.isSome: retweets.add tweet
|
||||||
#if tweet.retweetBy.isSome: retweets.add tweet
|
|
||||||
#end if
|
#end if
|
||||||
${renderTweet(tweet, "timeline-tweet")}
|
${renderTweet(tweet, "timeline-tweet")}
|
||||||
#end for
|
#end for
|
||||||
#if tweets.len > 0:
|
#if tweets.len > 0:
|
||||||
<div class="show-more">
|
<div class="show-more">
|
||||||
<a href="/${profile.username}?after=${$tweets[^1].id}">Load older tweets</a>
|
#let retweet = tweets[^1].retweetId.get("")
|
||||||
|
#let id = if retweet.len > 0: retweet else: tweets[^1].id
|
||||||
|
<a href="/${profile.username}?after=${$id}">Load older tweets</a>
|
||||||
</div>
|
</div>
|
||||||
#end if
|
#end if
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue