From 9848c2a31a2296b037a9ea6fc626d3bfa80fe019 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Sun, 22 Jan 2023 15:33:19 -0500 Subject: [PATCH] Small tweak --- src/components/VideoRowCell/VideoRowCell.bs | 65 +++++++++++---------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/src/components/VideoRowCell/VideoRowCell.bs b/src/components/VideoRowCell/VideoRowCell.bs index f0d39c9d..b994e288 100644 --- a/src/components/VideoRowCell/VideoRowCell.bs +++ b/src/components/VideoRowCell/VideoRowCell.bs @@ -1,42 +1,45 @@ import "pkg:/source/utils/TimeUtils.bs" -function OnContentSet() +function OnContentSet() as void content = m.top.itemContent - if content <> invalid - m.top.FindNode("titleLabel").text = content.title - m.top.FindNode("authorLabel").text = content.author + if content = invalid + return + end if - if IsVideoUpcoming(content) - m.top.FindNode("viewCountDateLabel").text = `Premeres in ${TimeUtils.GetFormattedTimeLeft(content.premiereTimestamp)}` + m.top.FindNode("titleLabel").text = content.title + m.top.FindNode("authorLabel").text = content.author + + if IsVideoUpcoming(content) + m.top.FindNode("viewCountDateLabel").text = `Premeres in ${TimeUtils.GetFormattedTimeLeft(content.premiereTimestamp)}` + else + publishedText = validstr(content.publishedText) + viewCount = FormatViewCount(content.viewCount) + if publishedText = "" and viewCount = "" + m.top.FindNode("viewCountDateLabel").text = "" else - publishedText = validstr(content.publishedText) - viewCount = FormatViewCount(content.viewCount) - if publishedText = "" and viewCount = "" - m.top.FindNode("viewCountDateLabel").text = "" - else - m.top.FindNode("viewCountDateLabel").text = `${publishedText} • ${viewCount}` - end if - end if - - m.thumbnail = m.top.FindNode("thumbnail") - m.thumbnail.observeField("loadStatus", "OnThumbnailLoadFailed") - m.thumbnail.uri = GetThumbnailUrl(content.videoThumbnails) - m.thumbnail.id = `thumbnail-${content.videoId}` - - if IsVideoLive(content) - m.top.FindNode("liveRect").visible = true - m.top.FindNode("durationRect").visible = false - else - m.top.FindNode("liveRect").visible = false - if content.lengthSeconds <> invalid and content.lengthSeconds <> 0 - m.top.FindNode("durationLabel").text = TimeUtils.GetFormattedTime(content.lengthSeconds) - m.top.FindNode("durationRect").visible = true - else - m.top.FindNode("durationRect").visible = false - end if + m.top.FindNode("viewCountDateLabel").text = `${publishedText} • ${viewCount}` end if end if + + m.thumbnail = m.top.FindNode("thumbnail") + m.thumbnail.observeField("loadStatus", "OnThumbnailLoadFailed") + m.thumbnail.uri = GetThumbnailUrl(content.videoThumbnails) + m.thumbnail.id = `thumbnail-${content.videoId}` + + if IsVideoLive(content) + m.top.FindNode("liveRect").visible = true + m.top.FindNode("durationRect").visible = false + else + m.top.FindNode("liveRect").visible = false + if content.lengthSeconds <> invalid and content.lengthSeconds <> 0 + m.top.FindNode("durationLabel").text = TimeUtils.GetFormattedTime(content.lengthSeconds) + m.top.FindNode("durationRect").visible = true + else + m.top.FindNode("durationRect").visible = false + end if + end if + end function function OnThumbnailLoadFailed() as void