Skip to content

Commit

Permalink
Use small video previews
Browse files Browse the repository at this point in the history
  • Loading branch information
zedeus committed Jun 7, 2020
1 parent 40ef239 commit a8553db
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/views/tweet.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import karax/[karaxdsl, vdom, vstyles]
import renderutils
import ".."/[types, utils, formatters]

proc getSmallPic(url: string): string =
result = url
if "?" notin url:
result &= ":small"
result = getPicUrl(result)

proc renderHeader(tweet: Tweet; retweet=""): VNode =
buildHtml(tdiv):
if retweet.len > 0:
Expand Down Expand Up @@ -52,7 +58,7 @@ proc isPlaybackEnabled(prefs: Prefs; video: Video): bool =

proc renderVideoDisabled(video: Video; path: string): VNode =
buildHtml(tdiv):
img(src=getPicUrl(video.thumb))
img(src=getSmallPic(video.thumb))
tdiv(class="video-overlay"):
case video.playbackType
of mp4:
Expand All @@ -62,7 +68,7 @@ proc renderVideoDisabled(video: Video; path: string): VNode =

proc renderVideoUnavailable(video: Video): VNode =
buildHtml(tdiv):
img(src=getPicUrl(video.thumb))
img(src=getSmallPic(video.thumb))
tdiv(class="video-overlay"):
case video.reason
of "dmcaed":
Expand All @@ -77,7 +83,7 @@ proc renderVideo*(video: Video; prefs: Prefs; path: string): VNode =
buildHtml(tdiv(class="attachments card")):
tdiv(class="gallery-video" & container):
tdiv(class="attachment video-container"):
let thumb = getPicUrl(video.thumb)
let thumb = getSmallPic(video.thumb)
if not video.available:
renderVideoUnavailable(video)
elif not prefs.isPlaybackEnabled(video):
Expand Down Expand Up @@ -108,7 +114,7 @@ proc renderGif(gif: Gif; prefs: Prefs): VNode =
buildHtml(tdiv(class="attachments media-gif")):
tdiv(class="gallery-gif", style={maxHeight: "unset"}):
tdiv(class="attachment"):
let thumb = getPicUrl(gif.thumb)
let thumb = getSmallPic(gif.thumb)
let url = getPicUrl(gif.url)
if prefs.autoplayGifs:
video(class="gif", poster=thumb, controls="", autoplay="", muted="", loop=""):
Expand Down

0 comments on commit a8553db

Please sign in to comment.