Skip to content

Commit

Permalink
Make view all buttom smart
Browse files Browse the repository at this point in the history
  • Loading branch information
jimdogx committed Jul 28, 2024
1 parent 15b41e7 commit 5a4b71c
Showing 1 changed file with 32 additions and 15 deletions.
47 changes: 32 additions & 15 deletions components/home/LoadItemsTask.bs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ sub loadItems()
end if
end if

addViewAll = true ' Assume there will be a "View All" to start
checkViewAll = false ' Only need to check if we don't have anything in the Next Up home row

resp = APIRequest(url, params)
data = getJson(resp)
if isValid(data) and isValid(data.Items)
Expand All @@ -93,22 +96,36 @@ sub loadItems()
tmp.json = item
results.push(tmp)
end for
' Add "View All"
' Note: Unfortunately you could have 0 items show up on the home screen and still have
' a bunch of items in NextUp that are > 365 days old. However, checking here for at
' least 1 item in Next Up means you won't have a "Next Up" section with nothing but a single View All folder.
if data.Items.Count() > 0
tmp = CreateObject("roSGNode", "HomeData")
tmp.type = "CollectionFolder"
tmp.usePoster = false
tmp.json = {
IsFolder: true,
Name: tr("View All Next Up"),
Type: "CollectionFolder",
CollectionType: "nextup"
}
results.push(tmp)
if data.Items.Count() = 0
checkViewAll = true
end if
else
checkViewAll = true
end if

' Add "View All"
if checkViewAll
' Nothing to show in Next Up, but are there hidden items (e.g. > 365 days old)?
params.Delete("NextUpDateCutoff")
params["limit"] = 1 ' if there is even one, then we know we need to show "View All"
resp = APIRequest(url, params)
data = getJson(resp)
if not isValid(data) or isValid(data) and isValid(data.Items) and data.Items.Count() = 0
addViewAll = false
end if
end if

if addViewAll
tmp = CreateObject("roSGNode", "HomeData")
tmp.type = "CollectionFolder"
tmp.usePoster = false
tmp.json = {
IsFolder: true,
Name: tr("View All Next Up"),
Type: "CollectionFolder",
CollectionType: "nextup"
}
results.push(tmp)
end if
' Load Continue Watching
else if m.top.itemsToLoad = "continue"
Expand Down

0 comments on commit 5a4b71c

Please sign in to comment.