Feature/channel view content (#150)

* ChannelView feeds

* Fixes for web app

* Add request id to error message
This commit is contained in:
Brahim Hadriche authored and GitHub committed 2023-09-22 17:52:53 -04:00
1 parent e2df0b524a
commit dab6dc5bc4
20 files changed
+414 -133

No files matched your search

@@ -0,0 +1,4 @@
enum PaginationType
Pages = "Pages"
Continuation = "Continuation"
end enum
@@ -1,5 +1,6 @@
import "pkg:/source/utils/TimeUtils.bs"
import "pkg:/source/utils/Types.bs"
import "pkg:/source/utils/StringUtils.bs"
function Init()
m.titleLabel = m.top.FindNode("titleLabel")
@@ -23,36 +24,30 @@ function OnContentSet() as void
m.titleLabel.text = content.title
m.authorLabel.text = content.author
if content.isUpcoming = true
m.viewCountDateLabel.text = content.premiereTimestampText
else
publishedText = ValidString(content.publishedText)
viewCountText = ValidString(content.viewCountText)
if publishedText = "" and viewCountText = ""
m.viewCountDateLabel.text = ""
else
m.viewCountDateLabel.text = `${publishedText} • ${viewCountText}`
if not StringUtils.IsNullOrEmpty(content.publishedText)
label = content.publishedText
if not StringUtils.IsNullOrEmpty(content.viewCountText)
label = `${label} • ${content.viewCountText}`
end if
m.viewCountDateLabel.text = label
else if content.isUpcoming = true
m.viewCountDateLabel.text = content.premiereTimestampText
end if
m.thumbnail.uri = content.thumbnail
if content.isUpcoming = true
m.upcomingRect.visible = true
m.liveRect.visible = false
m.durationRect.visible = false
else if content.liveNow
m.upcomingRect.visible = false
m.liveRect.visible = true
m.durationRect.visible = false
m.durationRect.visible = false
m.upcomingRect.visible = false
m.liveRect.visible = false
if ValidInt(content.lengthSeconds) <> 0
SetDurationText(content.lengthText)
m.durationRect.visible = true
else
m.upcomingRect.visible = false
m.liveRect.visible = false
if ValidInt(content.lengthSeconds) <> 0
SetDurationText(content.lengthText)
m.durationRect.visible = true
else
m.durationRect.visible = false
if content.isUpcoming = true
m.upcomingRect.visible = true
else if content.liveNow
m.liveRect.visible = true
end if
end if
end function
@@ -9,6 +9,8 @@ import "pkg:/components/VideoPlayer/VideoUtils.bs"
import "pkg:/components/PlaylistView/PlaylistUtils.bs"
import "pkg:/components/ChannelView/ChannelUtils.bs"
' TODO:P1 add the option to remove a row if it does not have any content
' E.g. NBC News does not return any related chnanels
function Init()
m.pendingLoadTasks = {}
end function
@@ -152,7 +154,7 @@ function GetRowsToLoad() as object
end if
subContentNodes = []
range = m.top.numRows + 2
range = m.top.numRows + 1
for i = -range to range
index = focus + i
if index < 0
@@ -172,6 +174,8 @@ function GetRowsToLoad() as object
end function
function LoadRowContent(contentNode as object)
LogInfo("Loading row content:", contentNode.title)
contentNode.loadState = FeedLoadState.Loading
task = StartAsyncTask(VideoRowListRowContentTask, {
node: m.top,
@@ -43,7 +43,7 @@ function VideoRowListRowContentTask(input as object) as object
instance = service.GetInstance()
itemNodes = []
for each item in response.result
for each item in response.result.items
itemNode = InvidiousContent.ToRowCellContentNode(item, instance)
if itemNode <> invalid
itemNodes.Push(itemNode)
@@ -53,8 +53,20 @@ function VideoRowListRowContentTask(input as object) as object
RemovePlaceHolderItems(contentNode)
contentNode.appendChildren(itemNodes)
if contentNode.pagination = true and response.result.Count() > 0
contentNode.loadState = FeedLoadState.LoadedPage
hasContinuation = not StringUtils.IsNullOrEmpty(response.result.continuation)
if hasContinuation
contentNode.continuation = response.result.continuation
end if
if response.result.items.Count() > 0
pageType = contentNode.paginationType
if pageType = PaginationType.Continuation and hasContinuation
contentNode.loadState = FeedLoadState.LoadedPage
else if pageType = PaginationType.Pages
contentNode.loadState = FeedLoadState.LoadedPage
else
contentNode.loadState = FeedLoadState.Loaded
end if
else
contentNode.loadState = FeedLoadState.Loaded
end if