From 31e6f01c08f9a353f787bb1fee287b7bd01fa613 Mon Sep 17 00:00:00 2001 From: 1hitsong <3330318+1hitsong@users.noreply.github.com> Date: Sat, 10 Dec 2022 17:41:22 -0500 Subject: [PATCH] Add unplayed count to homepage --- components/ItemGrid/GridItem.brs | 8 +++++--- components/ListPoster.brs | 8 +++++--- components/data/HomeData.brs | 4 ---- components/home/HomeItem.brs | 11 +++++++++-- components/home/HomeItem.xml | 8 +++++--- components/tvshows/TVEpisodes.brs | 8 +++++--- components/tvshows/TVShowDetails.brs | 8 +++++--- 7 files changed, 34 insertions(+), 21 deletions(-) diff --git a/components/ItemGrid/GridItem.brs b/components/ItemGrid/GridItem.brs index 7ccf90e7..162db0b9 100644 --- a/components/ItemGrid/GridItem.brs +++ b/components/ItemGrid/GridItem.brs @@ -43,9 +43,11 @@ sub itemContentChanged() m.itemIcon.uri = itemData.iconUrl m.itemText.text = itemData.Title else if itemData.type = "Series" - if itemData.json.UserData.UnplayedItemCount > 0 - m.unplayedCount.visible = true - m.unplayedEpisodeCount.text = itemData.json.UserData.UnplayedItemCount + if itemData?.json?.UserData?.UnplayedItemCount <> invalid + if itemData.json.UserData.UnplayedItemCount > 0 + m.unplayedCount.visible = true + m.unplayedEpisodeCount.text = itemData.json.UserData.UnplayedItemCount + end if end if m.itemPoster.uri = itemData.PosterUrl diff --git a/components/ListPoster.brs b/components/ListPoster.brs index 6374088e..ae04ef18 100644 --- a/components/ListPoster.brs +++ b/components/ListPoster.brs @@ -57,9 +57,11 @@ sub itemContentChanged() as void itemData = m.top.itemContent m.title.text = itemData.title - if itemData.json.UserData.UnplayedItemCount > 0 - m.unplayedCount.visible = true - m.unplayedEpisodeCount.text = itemData.json.UserData.UnplayedItemCount + if itemData?.json?.UserData?.UnplayedItemCount <> invalid + if itemData.json.UserData.UnplayedItemCount > 0 + m.unplayedCount.visible = true + m.unplayedEpisodeCount.text = itemData.json.UserData.UnplayedItemCount + end if end if if itemData.json.lookup("Type") = "Episode" and itemData.json.IndexNumber <> invalid diff --git a/components/data/HomeData.brs b/components/data/HomeData.brs index 66ecbb82..cae8c1e8 100644 --- a/components/data/HomeData.brs +++ b/components/data/HomeData.brs @@ -48,10 +48,6 @@ sub setData() imgParams = { "maxHeight": 261 } imgParams.Append({ "maxWidth": 464 }) - if datum.UserData.UnplayedItemCount > 0 - imgParams["UnplayedCount"] = datum.UserData.UnplayedItemCount - end if - m.top.posterURL = ImageURL(datum.id, "Primary", imgParams) ' Add Wide Poster (Series Backdrop) diff --git a/components/home/HomeItem.brs b/components/home/HomeItem.brs index 5b0e081e..938576cd 100644 --- a/components/home/HomeItem.brs +++ b/components/home/HomeItem.brs @@ -7,6 +7,8 @@ sub init() m.itemIcon = m.top.findNode("itemIcon") m.itemTextExtra = m.top.findNode("itemTextExtra") m.itemPoster.observeField("loadStatus", "onPosterLoadStatusChanged") + m.unplayedCount = m.top.findNode("unplayedCount") + m.unplayedEpisodeCount = m.top.findNode("unplayedEpisodeCount") m.showProgressBarAnimation = m.top.findNode("showProgressBar") m.showProgressBarField = m.top.findNode("showProgressBarField") @@ -24,19 +26,24 @@ sub itemContentChanged() if itemData = invalid then return itemData.Title = itemData.name ' Temporarily required while we move from "HomeItem" to "JFContentItem" - m.itemPoster.width = itemData.imageWidth m.itemText.maxWidth = itemData.imageWidth m.itemTextExtra.width = itemData.imageWidth m.itemTextExtra.visible = true - m.backdrop.width = itemData.imageWidth if itemData.iconUrl <> invalid m.itemIcon.uri = itemData.iconUrl end if + if itemData?.json?.UserData?.UnplayedItemCount <> invalid + if itemData.json.UserData.UnplayedItemCount > 0 + m.unplayedCount.visible = true + m.unplayedEpisodeCount.text = itemData.json.UserData.UnplayedItemCount + end if + end if + ' Format the Data based on the type of Home Data if itemData.type = "CollectionFolder" or itemData.type = "UserView" or itemData.type = "Channel" m.itemText.text = itemData.name diff --git a/components/home/HomeItem.xml b/components/home/HomeItem.xml index 3fb36250..74d9f064 100644 --- a/components/home/HomeItem.xml +++ b/components/home/HomeItem.xml @@ -3,12 +3,14 @@ - - + + + + -